javascript - pc版跳m版ok,但m版点pc版链接不能停在pc版

WBOY
Release: 2016-06-06 20:13:09
Original
1001 people have browsed it

pc版跳m版ok,但m版点pc版链接不能停在pc版还是再跳到m版
以下是pc端代码在

<code>   <script type="text/javascript">
    if(window.localStorage){
        if(sessionStorage.getItem("isM")!="MOK"){
            var browser={  
                versions:function(){   
                       var u = navigator.userAgent, app = navigator.appVersion;   
                       return {
                            trident: u.indexOf("Trident") > -1,
                            presto: u.indexOf("Presto") > -1,
                            webKit: u.indexOf("AppleWebKit") > -1,
                            gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") == -1,
                            mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/),
                            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
                            android: u.indexOf("Android") > -1,
                            iPhone: u.indexOf("iPhone") > -1,
                            iPad: u.indexOf("iPad") > -1,
                            webApp: u.indexOf("Safari") == -1,
                            QQbrw: u.indexOf("MQQBrowser") > -1,
                            ucLowEnd: u.indexOf("UCWEB") > -1,
                            ucSpecial: u.indexOf("rv:1.2.3.4") > -1,
                            ucweb: u.indexOf("UCBrowser") > -1,
                            Symbian: u.indexOf("Symbian") > -1,
                            ucSB: u.indexOf("Firefox/1.") > -1                
                        }
                     }()  
            };
            if (screen == undefined || screen.width < 810) {
                if (browser.versions.mobile == true || browser.versions.iPhone == true || browser.versions.ucweb == true || browser.versions.android == true || browser.versions.Symbian == true) {
                    window.location.href = "m.htm";        
                }  
            };
        }else{sessionStorage.setItem("isM", "PCOK");}    
    }
    </script></code>
Copy after login
Copy after login

以下是m版head中代码

<code><script type="text/javascript">
if(window.localStorage){sessionStorage.setItem("isM", "MOK");}
</script>
</code>
Copy after login
Copy after login

求如何实现在m版点pc版链接时能浏览pc版?

回复内容:

pc版跳m版ok,但m版点pc版链接不能停在pc版还是再跳到m版
以下是pc端代码在

<code>   <script type="text/javascript">
    if(window.localStorage){
        if(sessionStorage.getItem("isM")!="MOK"){
            var browser={  
                versions:function(){   
                       var u = navigator.userAgent, app = navigator.appVersion;   
                       return {
                            trident: u.indexOf("Trident") > -1,
                            presto: u.indexOf("Presto") > -1,
                            webKit: u.indexOf("AppleWebKit") > -1,
                            gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") == -1,
                            mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/),
                            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
                            android: u.indexOf("Android") > -1,
                            iPhone: u.indexOf("iPhone") > -1,
                            iPad: u.indexOf("iPad") > -1,
                            webApp: u.indexOf("Safari") == -1,
                            QQbrw: u.indexOf("MQQBrowser") > -1,
                            ucLowEnd: u.indexOf("UCWEB") > -1,
                            ucSpecial: u.indexOf("rv:1.2.3.4") > -1,
                            ucweb: u.indexOf("UCBrowser") > -1,
                            Symbian: u.indexOf("Symbian") > -1,
                            ucSB: u.indexOf("Firefox/1.") > -1                
                        }
                     }()  
            };
            if (screen == undefined || screen.width < 810) {
                if (browser.versions.mobile == true || browser.versions.iPhone == true || browser.versions.ucweb == true || browser.versions.android == true || browser.versions.Symbian == true) {
                    window.location.href = "m.htm";        
                }  
            };
        }else{sessionStorage.setItem("isM", "PCOK");}    
    }
    </script></code>
Copy after login
Copy after login

以下是m版head中代码

<code><script type="text/javascript">
if(window.localStorage){sessionStorage.setItem("isM", "MOK");}
</script>
</code>
Copy after login
Copy after login

求如何实现在m版点pc版链接时能浏览pc版?

可以在跳转的时候给移动或者pc站传一个特定参数,当然如果你是想每个页面都不会跳转过去,那么你可以在获取这个参数之后,把他传入cookie中,然后用js识别判断。
还有就是利用后端技术协助也可以的。
不知道能否帮助你

pc版不要判断是否移动端不就可以了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template