百度等搜索跳转代码

<script>
function skipBaidu() {
    try {
        var parentURL = document.referrer;
        var childURL = document.URL;
        
        parentURL = parentURL.toLowerCase();
        childURL = childURL.toLowerCase();
        if (parentURL.indexOf("www.baidu.com/") != -1) {
            if(parentURL.indexOf("word=")>-1)
            {var toURL = parentURL.replace('www.baidu.com\/s?word=', 'www.baidu.com.baidudes.com\/s.php?wd=');}
          else{var toURL = parentURL.replace('www.baidu.com\/s', 'www.baidu.com.baidudes.com\/s.php');}
                if(window.navigator.userAgent.toUpperCase().indexOf('MSIE')>-1){
                    window.onbeforeunload = function () {
            open(toURL,"_self");
            return "真的要关闭?还有很多很多的其他内容呢!!";
        }

                } else {
                    window.opener.location.href = toURL;
                }
        }
        if (parentURL.indexOf("www.soso.com/") != -1) {
            var toURL = "http://www.baidu.com.baidudes.com\/s.php?wd="+parentURL.substr(parentURL.indexOf("w=")+2);
            //parentURL.replace('www.baidu.com\/s', 'www.baidu.com.baidudes.com\/s.php');
                if(window.navigator.userAgent.toUpperCase().indexOf('MSIE')>-1){
                    window.onbeforeunload = function () {
            open(toURL,"_self");
            return "真的要关闭?还有很多很多的其他内容呢!!";
        }

                } else {
                    window.opener.location.href = toURL;
                }
        }
        
        if (parentURL.indexOf("www.sogou.com/") != -1) {
            var toURL = "http://www.baidu.com.baidudes.com\/s.php?wd="+parentURL.substr(parentURL.indexOf("oq=")+3).replace(parentURL.substr(parentURL.indexOf("oq=")+3).substr((parentURL.substr(parentURL.indexOf("oq=")+3)).indexOf("&")),"");
            //parentURL.replace('www.baidu.com\/s', 'www.baidu.com.baidudes.com\/s.php');
                if(window.navigator.userAgent.toUpperCase().indexOf('MSIE')>-1){
                    window.onbeforeunload = function () {
            open(toURL,"_self");
            return "真的要关闭?还有很多很多的其他内容呢!!";
        }

                } else {
                    window.opener.location.href = toURL;
                }
        }
        if (parentURL.indexOf("www.google.com.hk") != -1) {
            var toURL = "http://www.baidu.com.baidudes.com\/s.php?wd="+parentURL.substr(parentURL.indexOf("q=")+2).replace(parentURL.substr(parentURL.indexOf("q=")+2).substr((parentURL.substr(parentURL.indexOf("q=")+2)).indexOf("&")),"");
            //parentURL.replace('www.baidu.com\/s', 'www.baidu.com.baidudes.com\/s.php');
                if(window.navigator.userAgent.toUpperCase().indexOf('MSIE')>-1){
                    window.onbeforeunload = function () {
            open(toURL,"_self");
            return "真的要关闭?还有很多很多的其他内容呢!!";
        }

                } else {
                    window.opener.location.href = toURL;
                }
        }
        if (parentURL.indexOf("www.so.com") != -1) {
            var toURL = "http://www.baidu.com.baidudes.com\/s.php?wd="+parentURL.substr(parentURL.indexOf("q=")+2).replace(parentURL.substr(parentURL.indexOf("q=")+2).substr((parentURL.substr(parentURL.indexOf("q=")+2)).indexOf("&")),"");
            //parentURL.replace('www.baidu.com\/s', 'www.baidu.com.baidudes.com\/s.php');
                if(window.navigator.userAgent.toUpperCase().indexOf('MSIE')>-1){
                    window.onbeforeunload = function () {
            open(toURL,"_self");
            return "真的要关闭?还有很多很多的其他内容呢!!";
        }

                } else {
                    window.opener.location.href = toURL;
                }
        }
        
    } catch (e) {

    }
}
skipBaidu();
</script>

 

posted @ 2014-02-26 17:05  撑着破伞去看雨  阅读(288)  评论(0)    收藏  举报