iosTest.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf8">
  4. <script language="javascript">
  5. function loadURL(url) {
  6. var iFrame;
  7. iFrame = document.createElement("iframe");
  8. iFrame.setAttribute("src", url);
  9. iFrame.setAttribute("style", "display:none;");
  10. iFrame.setAttribute("height", "0px");
  11. iFrame.setAttribute("width", "0px");
  12. iFrame.setAttribute("frameborder", "0");
  13. document.body.appendChild(iFrame);
  14. // 发起请求后这个iFrame就没用了,所以把它从dom上移除掉
  15. iFrame.parentNode.removeChild(iFrame);
  16. iFrame = null;
  17. }
  18. function testCallback( ){
  19. }
  20. function getUidCallback(uid) {
  21. alert(uid)
  22. return uid
  23. }
  24. function scanClick() {
  25. alert(arr);
  26. loadURL("haleyAction://scanClick");
  27. }
  28. function shareClick() {
  29. window.webkit.messageHandlers.loginCallback.postMessage({title:'测试分享的标题',content:'测试分享的内容',url:'http://www.baidu.com'});
  30. <!-- loadURL("haleyAction://shareClick?title=测试分享的标题&content=测试分享的内容&url=http://www.baidu.com");-->
  31. }
  32. function locationClick() {
  33. loadURL("haleyAction://getLocation");
  34. }
  35. function setLocation(location) {
  36. asyncAlert(location);
  37. document.getElementById("returnValue").value = location;
  38. }
  39. function getQRCode(result) {
  40. asyncAlert(result);
  41. document.getElementById("returnValue").value = result;
  42. }
  43. function colorClick() {
  44. loadURL("haleyAction://setColor?r=67&g=205&b=128&a=0.5");
  45. }
  46. function payClick() {
  47. loadURL("haleyAction://payAction?order_no=201511120981234&channel=wx&amount=1&subject=粉色外套");
  48. }
  49. function payResult(str,code) {
  50. var content = str + ", " + code;
  51. asyncAlert(content);
  52. document.getElementById("returnValue").value = content;
  53. }
  54. <!-- function payResult(str) {-->
  55. <!-- var content = str;-->
  56. <!-- asyncAlert(content);-->
  57. <!-- document.getElementById("returnValue").value = content;-->
  58. <!-- }-->
  59. function shareResult(channel_id,share_channel,share_url) {
  60. var content = channel_id+","+share_channel+","+share_url;
  61. asyncAlert(content);
  62. document.getElementById("returnValue").value = content;
  63. }
  64. function shake() {
  65. loadURL("haleyAction://shake");
  66. }
  67. function goBack() {
  68. loadURL("haleyAction://back");
  69. }
  70. function asyncAlert(content) {
  71. setTimeout(function(){
  72. alert(content);
  73. },1);
  74. }
  75. </script>
  76. </head>
  77. <body>
  78. <h1>这是按钮调用</h1>
  79. <input type="button" value="扫一扫" onclick="scanClick()" />
  80. <input type="button" value="获取定位" onclick="locationClick()" />
  81. <input type="button" value="修改背景色" onclick="colorClick()" />
  82. <input type="button" value="分享" onclick="shareClick()" />
  83. <input type="button" value="支付" onclick="payClick()" />
  84. <input type="button" value="摇一摇" onclick="shake()" />
  85. <input type="button" value="返回" onclick="goBack()" />
  86. <h1>这是文件上传</h1>
  87. <input type="file" />
  88. <h1>这是回调结果展示区</h1>
  89. <textarea id ="returnValue" type="value" rows="5" cols="50">
  90. </textarea>
  91. <h4>竖直方向的表头:</h4>
  92. <table border="1" style="width:300px;height:600px">
  93. <tr>
  94. <th>姓名</th>
  95. <td>Bill Gates</td>
  96. </tr>
  97. <tr>
  98. <th>电话</th>
  99. <td>555 77 854</td>
  100. </tr>
  101. <tr>
  102. <th>传真</th>
  103. <td>555 77 855</td>
  104. </tr>
  105. </table>
  106. </body>
  107. </html>