移动重定向,但来自移动网站时不重定向
Mobile redirect but not when coming from Mobile site
我有这个脚本,它运行得很好。我在桌面页面上有它,当用户输入它时,他们会收到一个问题,并将其重定向到移动页面,这很好。但我在手机页面上有一个返回桌面页面的链接,但当这个链接被点击,用户进入桌面页面时,他们将再次获得该链接。所以我的问题是。有没有办法让桌面页面知道用户已经点击了移动页面中的链接,如果是,就不再显示问题?非常感谢。
我现在拥有的代码:
<script type="text/javascript">
var isMobile = (/iphone|ipod|android|blackberry|mini|windows'sce|palm/i.test(navigator.userAgent) && confirm('Realy?'));
if (isMobile)
{
location.replace("mobile_site.html");
}
</script>
所以我也有这个代码。有人知道如何将我的第一个剧本与这个结合起来吗?非常感谢。
<script>
if( /Android|webOS|iPhone|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent) &&
!window.location.href.contains("#redirected") ) {
window.location = "my_mobile_page.html";
}
</script>
这应该做到-只有在用户设备isMobile
并且用户还没有从该移动站点链接的情况下,才重定向到您的移动站点:
<script type="text/javascript">
var referrer = document.referrer;
var isMobile = (/iphone|ipod|android|blackberry|mini|windows'sce|palm/i.test(navigator.userAgent) && confirm('Realy?'));
if (isMobile && referrer != 'mobile_site.html')
{
location.replace("mobile_site.html");
}
</script>
编辑:修改代码以删除确认。如果用户的设备是移动的,而推荐人不是移动网站,则会显示确认提示。如果用户接受,将触发重定向。如果用户从移动站点返回,则不会显示确认信息。
<script type="text/javascript">
var referrer = document.referrer;
if (/iphone|ipod|android|blackberry|mini|windows'sce|palm/i.test(navigator.userAgent) && referrer != 'mobile_site.html')
{
var r = confirm("Really");
if (r == true) {
location.replace("mobile_site.html");
} else {
stop;
}
}
</script>
相关文章:
- Javascript移动站点重定向问题
- 移动网站重定向问题
- Javascript移动重定向问题
- 移动站点重定向与完整的站点链接
- 简单的移动重定向/深度链接实施
- 移动重定向,但来自移动网站时不重定向
- HTML Javascript移动重定向
- JS移动重定向到/mobile/而不是m
- 移动重定向和完整网站到子域
- BuzzFeed是如何进行移动重定向的
- 将 Jquery 移动重定向到新页面,并触发此页面中的函数
- 在网站上使用target_blank甚至在桌面上也会强制移动重定向
- 移动重定向并使用cookie返回桌面
- 移动重定向与joomla没有htaccess
- 无缝移动重定向脚本
- 使用iWeb创建我的网站,但移动重定向不工作
- Javascript移动重定向问题
- 移动重定向使用屏幕分辨率
- 这是一个很好的移动重定向javascript吗?或者我会被谷歌封杀
- 移动重定向不起作用