admin管理员组文章数量:1384207
I'm using the javascript version from / to redirect to a mobile site. The only thing is that I have a link to go to the full site in the off chance that users want/need to go there.
However, when you click on the link to view the full site from the mobile, it picks back up on the redirection and kicks it back to the mobile version and not to the full site.
I was doing some searching and was wondering if it could be possible to hack it so that it uses
window.location.href.indexOf
or somthing of that nature like this:
if(window.location.href.indexOf("mobile/index.html") > -1)
{window.location = ""}
else { function (a, b) {
if (//mobile direction stuff from detectmobilebrowsers
})(navigator.userAgent || navigator.vendor || window.opera,
'.html')};
Keep in mid that this is something that I pieced together and my JS skills are fairly new, so if any one has a more elegant solution I am all for it.
I'm using the javascript version from http://detectmobilebrowsers./ to redirect to a mobile site. The only thing is that I have a link to go to the full site in the off chance that users want/need to go there.
However, when you click on the link to view the full site from the mobile, it picks back up on the redirection and kicks it back to the mobile version and not to the full site.
I was doing some searching and was wondering if it could be possible to hack it so that it uses
window.location.href.indexOf
or somthing of that nature like this:
if(window.location.href.indexOf("mobile/index.html") > -1)
{window.location = "http://thefullsiteURL."}
else { function (a, b) {
if (//mobile direction stuff from detectmobilebrowsers.
})(navigator.userAgent || navigator.vendor || window.opera,
'http://thefullsiteURL./mobile/index.html')};
Keep in mid that this is something that I pieced together and my JS skills are fairly new, so if any one has a more elegant solution I am all for it.
Share Improve this question asked Aug 27, 2012 at 15:16 ultraloveninjaultraloveninja 2,1397 gold badges34 silver badges70 bronze badges1 Answer
Reset to default 6Set a session cookie in conjunction with a querystring value in your full site link. Then, have your mobile detect code check first for the cookie value, second for the query string, and last for user agent mobile detect.
So your full site link should be something like with the query string trigger:
<a href='http://mysite.?fullsite=true'>Link to full site</a>
And then in your mobile detect:
;(function(a,b) {
if (document.cookie.indexOf('fullsite') > -1) {
return; // skip redirect
}
if (location.search.indexOf('fullsite') > -1) {
document.cookie = 'fullsite=true; path=/;'
return; // skip redirect
}
if (/mobile regex conditional goes here/) {
window.location = b;
}
})(navigator.userAgent || navigator.vendor || window.opera, 'http://thefullsiteURL./mobile/index.html')
本文标签: javascriptmobile site redirect with full site linkStack Overflow
版权声明:本文标题:javascript - mobile site redirect with full site link - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744530449a2611001.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论