template.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE html>
  2. <html lang=zh-CN>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1">
  7. <style type="text/css">
  8. body{
  9. margin: 0;
  10. background-color: #f3f3f3;
  11. }
  12. iframe{
  13. width: 375px;
  14. height: 667px;
  15. background-color: #fff;
  16. box-sizing: content-box;
  17. border: none;
  18. }
  19. @media screen and (min-width: 450px) {
  20. iframe {
  21. position: fixed;
  22. top: 0;
  23. right: 0;
  24. bottom: 0;
  25. left: 0;
  26. margin: auto;
  27. border: rgba(0,0,0,0.7) solid 2px;
  28. border-radius: 4px;
  29. }
  30. }
  31. </style>
  32. <script type="text/javascript">
  33. window.isPC = true;
  34. window.onload = function(){
  35. /* 监听电脑浏览器窗口尺寸改变 */
  36. window.onresize = function(){
  37. /* 窗口宽度 小于或等于420px 时,跳转回H5页面 */
  38. if(window.innerWidth <= 420){
  39. console.log('window.innerWidth <= 420');
  40. window.location.pathname = '/TracerMethodology';
  41. /* 若你的项目未设置根目录(默认为 / 时),则使用下方代码 */
  42. // window.location.pathname = '';
  43. }
  44. }
  45. }
  46. </script>
  47. </head>
  48. <body>
  49. <!-- <iframe id="frame" ></iframe> -->
  50. <!--
  51. 若你的项目未设置根目录(默认为 / 时),则使用下方代码
  52. <iframe src="/"></iframe>
  53. -->
  54. </body>
  55. <script type="text/javascript">
  56. // console.log('iframe',document.getElementById('frame'));
  57. function createIframe(id,url,width,height,onLoadCallback,timeOut,timeOutCallback){
  58. var timeOutVar = setTimeout(function(){
  59. clearTimeout(timeOutVar);
  60. timeOutCallback.apply(this, arguments);
  61. return ;
  62. }, timeOut);
  63. var iframe = document.createElement("iframe");
  64. iframe.id=id;
  65. iframe.width=width;
  66. iframe.height=height;
  67. iframe.src=url;
  68. if (iframe.attachEvent){
  69. iframe.attachEvent("onload", function(){
  70. clearTimeout(timeOutVar);
  71. onLoadCallback.apply(this, arguments);
  72. });
  73. } else {
  74. iframe.onload = function(){
  75. clearTimeout(timeOutVar);
  76. onLoadCallback.apply(this, arguments);
  77. };
  78. }
  79. document.body.appendChild(iframe);
  80. return iframe;
  81. }
  82. function onLoadCallback(){
  83. console.log('onLoadCallback');
  84. }
  85. function timeOutCallback(){
  86. console.log('timeOutCallback');
  87. }
  88. let hospSign = '';
  89. let query = window.location.search.substring(1);
  90. let vars = query.split("=");
  91. for (let i=0;i<vars.length;i++) {
  92. if(vars[i] == 'hospSign'){
  93. hospSign=vars[i+1];
  94. }
  95. }
  96. // localStorage.removeItem('hospSign');
  97. // localStorage.setItem('hospSign',hospSign);
  98. let url = `/TracerMethodology?hospSign=${hospSign}`;
  99. console.log({hospSign,query,url});
  100. createIframe(
  101. 'frame',
  102. url,
  103. '100vw',
  104. '100vh',
  105. onLoadCallback,
  106. 1000,
  107. timeOutCallback
  108. );
  109. </script>
  110. </html>