HTML页面自动跳转到第三方页面

项目需要引用其他公司的页面,于是学习了一下跳转的方法。这里提供两种方法!

  1. 第一种:直接跳转
    直接写在head中即可!
    (这里对meta不了解的可以看我的这篇文章
<head>
    <meta http-equiv="Content-Language" content="zh-CN">    //设定语言
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">  //旧版设定字符集。
   // <meta charset="utf-8">   HTML5的字符集设定,推荐“UTF-8”。这两种二选一。
    <meta http-equiv="refresh" content="0.1;url=//www.baidu.com/">  //设置跳转时间和目标路径。
    <title></title>
</head>
  1. 第二中:X秒后跳转

     < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <title></title> 
               <style type="text/css">
                    #dv{border:4px #E8E8E9 double;margin:auto;width:600px;height:300px;background-color:#E8E8E8;
                    /*设置透明度*/
                    filter:alpha(opacity=50); -moz-opacity:0.6; -khtml-opacity: 0.6; opacity: 0.6;}
                    .top{border:0px #0000FF solid;width:400px;height:40px;margin:auto;margin-top:12px;}
                    .top li{border:0px #00FF00 solid;width:180px;height:40px;float:left;list-style:none;text-height:40px;line-height:40px;}
                    .top .top_one{width:70px;height:40px;margin-left:80px;}
                    .top #setTime{color:#900;width:30px;height:40px;font-size:36px;text-align:center;}
                    .bottom{border:0px #0000FF solid;width:400px;height:40px;margin:auto;margin-top:160px;}
                    .bottom li{border:0px #00FF00 solid;width:120px;height:40px;float:left;list-style:none;line-height:40px;}
                    .bottom .bottom_one{width:100px;height:40px;margin-left:220px;}
                    .bottom .bottom_two{width:70px;height:40px;}
                    .bottom .bottom_two a:hover{color:#F00;}
                    .bottom .bottom_two a{text-decoration:none;color:#0F0;}
               </style>    
    </head>
    <body bgColor="#f7f7f7">
        <div id = "dv" >
                <ul class="top">
                    <li class="top_one">网页将在</li>
                    <li id="setTime"></li>
                    <li>秒后自动跳转......</li>
                </ul>
                <ul class="bottom">
                    <li class="bottom_one">如果未跳转请</li>
                    <li class="bottom_two"><a href="http://www.baidu.com">点击此处</a></li>
                </ul>   //此处添加跳转的url
        </div>
       <!--定时器-->
        <script type="text/javascript">
        var i = 1;
        var tId;
        document.getElementById("setTime").innerHTML = i;
        function showTime(){
            if(i == 0){
                window.clearInterval(tId);
                return;
            }
            i--;
            document.getElementById("setTime").innerHTML = i;
            if(i == 0){  //如果时间秒数为0,跳转到指定页面
                location.replace("http://www.baidu.com");  //跳转的url
            }
        }
        window.setInterval(showTime,1000);
    
    	</script>
             <!--保持网页不变形-->
           <script type="text/javascript">
            var a=screen.availWidth;
            var b=screen.availHeight;
            window.moveTo(0,0)
            window.resizeTo(a,b)
    	</script>
    </body>
    </html>
    
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冉木

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值