template.html 3.7 KB

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