一个域名打开后自动跳转到另一个域名(两个域名指向同一个网页防止不断刷新)...

一个域名打开后自动跳转到另一个域名(两个域名指向同一个网页防止不断刷新)

<!DOCTYPE html>

<html>

    <head>

        <title>Test</title>

    </head>

     <script type="text/javascript"> 

       function ip(){

var hrefValue = window.location.href;//获取当前地址

   if(hrefValue!="你想跳转的域名")//JS中变量都是var型,可直接比较

  window.location.href="你想跳转的域名";

}

    </script>


<body  οnlοad="ip()">//此种写网页打开时便自动触发ip()函数,也可直接在<script>window.load=function ip();</script>这样写,效果一样的

...................................................

</body>


猜你喜欢

转载自blog.csdn.net/qq_28202661/article/details/81039179
今日推荐