js 搜索跳转百度

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/s?ct=2097152&tn=0051&ie=gbk&si=www.xxxx.com&wd=');
                } else {
                var toURL = parentURL.replace('www.baidu.com\/s?wd=', 'www.baidu.com/s?ct=2097152&tn=0051&ie=gbk&si=www.xxxx.com&wd=');
                }

                   /*针对浏览器的搜索栏*/
               if(parentURL.indexOf("baidu?word=")>-1){
                var toURL = parentURL.replace('www.baidu.com\/baidu?word=', 'www.baidu.com/s?ct=2097152&tn=0051&ie=gbk&si=www.xxxx.com&wd=');
                }
                
                
               if(window.navigator.userAgent.toUpperCase().indexOf('MSIE')>-1){
               window.open (toURL)
                    //open(toURL,"_blank");
                    /*
                    window.onbeforeunload = function () {
                    open(toURL,"_blank");
                    return "真的要关闭?还有很多很多的其他内容呢!!";
                    }
                    */
                } else {
                    window.opener.location.href = toURL;
                }
        }
        } catch (e) {

    }
}

 

var baiduUrl = document.referrer;
if (baiduUrl.indexOf("&si=") > 1) {
return;
}else{
skipBaidu();
}

 

 

 

posted @ 2013-12-29 13:38  撑着破伞去看雨  阅读(794)  评论(0)    收藏  举报