分享一个简单的跳转网页代码

分享一个简单的跳转网页代码 - 全民博客

没啥好说的,直接上代码,可以运行看效果,喜欢的就直接复制吧。

HTML
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <meta http-equiv="refresh" content="30;url='http://nidecms.com/';">
  8. <title>即将离开本网站,请注意账号财产安全</title>
  9. <style>
  10. html{background:#f4f5f5}
  11. #box{margin:auto;background:#fff;padding:10px 30px;margin-top:10%;max-width:500px;box-sizing:border-box;border:1px solid #e5e6eb;border-radius:2px}
  12. .note{font-size:18px;line-height:20px}
  13. .link{padding:16px 0 24px;border-bottom:1px solid #e5e6eb;position:relative;color:gray;font-family:"PingFang SC";font-size:14px;word-break:break-all}
  14. .btn-plane{text-align:right}
  15. button{margin-top:20px;color:#fff;border-radius:3px;border:none;background:#007fff;height:32px;font-size:14px;padding:0 14px;cursor:pointer;outline:0}
  16. button a{color:#fff;text-decoration:none}
  17. </style>
  18. </head>
  19. <body>
  20. <div id="box">
  21.     <p>即将离开本网站,请注意账号财产安全</p>
  22.     <p>http://nidecms.com/</p>
  23.     <p>
  24.      <button><a id="close" onclick="closePage()">关闭页面</a></button> <button><a id="UrlId" href="http://nidecms.com/" rel="nofollow">继续访问</a></button>
  25.     </p>
  26. </div>
  27. <script>
  28. function closePage() {
  29.     /* 设个定时器,如果页面未关闭,则跳转至首页 */
  30.     setTimeout(function() {
  31.         window.location.href = 'http://nidecms.com/';
  32.     },
  33.     300);
  34.     /* 通用窗口关闭 */
  35.     window.opener = null;
  36.     window.open('', '_self');
  37.     window.close();
  38.     /* 微信浏览器关闭 */
  39.     WeixinJSBridge.call('closeWindow');
  40. }
  41. </script>
  42. </body>
  43. </html>

可以实现自动跳转,这是还没有封装的,自己封装吧,封装起来也不难的啊。

本文结束

评论专区

发表评论

评论列表(无评论)