template.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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:100vh;
  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. if(window.innerWidth <= 420){
  36. window.location.pathname = '/TracerMethodology';
  37. }
  38. /* 监听电脑浏览器窗口尺寸改变 */
  39. window.onresize = function(){
  40. /* 窗口宽度 小于或等于420px 时,跳转回H5页面 */
  41. if(window.innerWidth <= 420){
  42. console.log('window.innerWidth <= 420');
  43. window.location.pathname = '/TracerMethodology';
  44. /* 若你的项目未设置根目录(默认为 / 时),则使用下方代码 */
  45. // window.location.pathname = '';
  46. }
  47. }
  48. }
  49. </script>
  50. </head>
  51. <body>
  52. <!-- <iframe id="frame" ></iframe> -->
  53. <!--
  54. 若你的项目未设置根目录(默认为 / 时),则使用下方代码
  55. <iframe src="/"></iframe>
  56. -->
  57. </body>
  58. <script type="text/javascript">
  59. // console.log('iframe',document.getElementById('frame'));
  60. function createIframe(id,url,width,height,onLoadCallback,timeOut,timeOutCallback){
  61. var timeOutVar = setTimeout(function(){
  62. clearTimeout(timeOutVar);
  63. timeOutCallback.apply(this, arguments);
  64. return ;
  65. }, timeOut);
  66. var iframe = document.createElement("iframe");
  67. iframe.id=id;
  68. iframe.width=width;
  69. iframe.height=height;
  70. iframe.src=url;
  71. if (iframe.attachEvent){
  72. iframe.attachEvent("onload", function(){
  73. clearTimeout(timeOutVar);
  74. onLoadCallback.apply(this, arguments);
  75. });
  76. } else {
  77. iframe.onload = function(){
  78. clearTimeout(timeOutVar);
  79. onLoadCallback.apply(this, arguments);
  80. };
  81. }
  82. document.body.appendChild(iframe);
  83. return iframe;
  84. }
  85. function onLoadCallback(){
  86. console.log('onLoadCallback');
  87. }
  88. function timeOutCallback(){
  89. console.log('timeOutCallback');
  90. }
  91. let hospSign = '';
  92. let query = window.location.search.substring(1);
  93. let vars = query.split("=");
  94. for (let i=0;i<vars.length;i++) {
  95. if(vars[i] == 'hospSign'){
  96. hospSign=vars[i+1];
  97. }
  98. }
  99. // localStorage.removeItem('hospSign');
  100. // localStorage.setItem('hospSign',hospSign);
  101. let url = `/TracerMethodology?hospSign=${hospSign}`;
  102. // console.log({hospSign,query,url});
  103. createIframe(
  104. 'frame',
  105. url,
  106. '100vw',
  107. '100vh',
  108. onLoadCallback,
  109. 1000,
  110. timeOutCallback
  111. );
  112. </script>
  113. </html>