linktoWC.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>公众号跳转</title>
  7. <style>
  8. *{
  9. margin: 0;
  10. padding: 0;
  11. -webkit-user-select: none;
  12. -webkit-tap-highlight-color: rgba(200,200,200,0);
  13. }
  14. body{
  15. background: #fff;
  16. }
  17. a{
  18. color: #000;
  19. position: fixed;
  20. top: 50%;
  21. left: 50%;
  22. transform: translate(-50%,-50%);
  23. }
  24. a{
  25. width: 100%;
  26. height: 100%;
  27. text-decoration: none;
  28. background: url(./bg.png) no-repeat;
  29. background-size: cover;
  30. background-position: 50% 50%;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <a id="link" target="_blank" href=""></a>
  36. <script>
  37. function getQueryString(name) {
  38. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  39. var r = window.location.search.substr(1).match(reg);
  40. if (r != null) return decodeURI(r[2]); return null;
  41. }
  42. let link = document.querySelector('#link')
  43. let url = decodeURIComponent(getQueryString('url'))
  44. link.href = url
  45. document.querySelector('#link').addEventListener('click',function (e) {
  46. console.log('closePop')
  47. window.top.postMessage('closePop','*')
  48. })
  49. </script>
  50. </body>
  51. </html>