简体   繁体   English

移动网站重定向,完整网站链接,不包含Cookie。 Cookie似乎阻止了返回移动网站

[英]Mobile website redirect, Full Site link, without cookie. Cookie seems to prevent return to mobile site

I'm testing a few JavaScripts that redirect mobile users from a main website to a mobile website. 我正在测试一些将移动用户从主网站重定向到移动网站的JavaScript。 What I have found uses cookies however, and the cookies seem to prevent returning users from going directly back to the mobile website, without clearing the browser's cookies, not just closing browser. 但是,我发现使用的是cookie,并且cookie似乎可以防止返回用户直接返回移动网站,而无需清除浏览器的cookie,而不仅仅是关闭浏览器。

Can I do this with a variable instead of a cookie? 我可以使用变量而不是Cookie来执行此操作吗? Or PHP? 还是PHP?

This simple script looks like it uses use a file value stored, but I can't get it to work. 这个简单的脚本看起来像使用了存储的文件值,但我无法使其正常工作。

<script>
if (document.location.search.indexOf("skipmobile") >= 0) {
document.cookie = "skipmobile=1";
}
else if ((document.location.hostname.match(/\.mobi$/) || screen.width < 699)
&& document.cookie.indexOf("skipmobile") == -1)
{
document.location = "mobile/";
}
</script>`

Mobile side link to full site has this ending: http://www.domain.com/?skipmobile=1 ` 指向完整网站的移动端链接的结尾是: http : //www.domain.com/? skipmobile = 1`

Any suggestions appreciated. 任何建议表示赞赏。

I chanced upon this article that you have, I am Neil and I work for handsetdetection.com. 我偶然发现了您的这篇文章,我是Neil,我在phonedetection.com工作。 Just to let everyone of your reader know that there is also another way of redirecting your viewer to a mobile site that you have and automatically adjust the screen size and buttons to whatever type of mobile device they are using. 只是让所有读者都知道,还有另一种方法可以将查看器重定向到您拥有的移动站点,并自动将屏幕大小和按钮调整为他们使用的任何类型的移动设备。 However, having a mobile version of your site is not enough, you have to redirect your visitors from your main website to a mobile version of your site. 但是,仅拥有移动版本的网站是不够的,您必须将访问者从主网站重定向到移动版本的网站。 It is called handsetdetection and it is quite easy to install as a plug in to any back end of your site. 这称为手机检测,可以很容易地作为插件安装到站点的任何后端。 Hope this helps, Neil Summers 希望这会有所帮助,尼尔·萨默斯(Neil Summers)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM