正在读取数据,页面载入中,请稍后...

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

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

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="refresh" content="30;url='http://nidecms.com/';">
<title>即将离开本网站,请注意账号财产安全</title>
<style>
html{background:#f4f5f5}
#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}
.note{font-size:18px;line-height:20px}
.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}
.btn-plane{text-align:right}
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}
button a{color:#fff;text-decoration:none}
</style>
</head>
<body>
<div id="box">
    <p>即将离开本网站,请注意账号财产安全</p>
    <p>http://nidecms.com/</p>
    <p>
     <button><a id="close" onclick="closePage()">关闭页面</a></button> <button><a id="UrlId" href="http://nidecms.com/" rel="nofollow">继续访问</a></button>
    </p>
</div>
<script>
function closePage() {
    /* 设个定时器,如果页面未关闭,则跳转至首页 */
    setTimeout(function() {
        window.location.href = 'http://nidecms.com/';
    },
    300);
    /* 通用窗口关闭 */
    window.opener = null;
    window.open('', '_self');
    window.close();
    /* 微信浏览器关闭 */
    WeixinJSBridge.call('closeWindow');
}
</script>
</body>
</html>

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

本文结束

评论专区

发表评论

评论列表(无评论)