繁体   English   中英

仅在桌面上重定向Safari浏览器

[英]Redirect Safari Browser on a Desktop only

我试图仅在桌面上重定向Safari浏览器。 标题中有一个视频,其中背景颜色与标题背景匹配。 问题是OS X上的Safari显示颜色不同。 在iPad和iPhone的Safari上,颜色正确,与Chrome,IE和Firefox匹配。 因此,我设置了不同的颜色背景来仅与Safari桌面上的视频匹配,但是当我将浏览器重定向到Safari时,它也重定向了iPad和iPhone,这随后显示了颜色问题。

var uagent = navigator.userAgent.toLowerCase();
if(/safari/.test(uagent) && !/chrome/.test(uagent))
{
    window.location.href = "index_safari.html"
}

任何建议只针对桌面上的Safari并允许ios上的Safari浏览器停留在该页面上的建议,将不胜感激。

http://webedelic.com/webedelic/index.html

您可以使用navigator.userAgent确定操作系统以及浏览器详细信息。

根据此值使用类。

我似乎无法在一个脚本中做到这一点,我很想这样做。

第一次重定向

var uagent = navigator.userAgent.toLowerCase();
if(/safari/.test(uagent) && !/chrome/.test(uagent))
{
    window.location.href = "index_safari.html"
}

然后返回索引的复制页面,以获取ipad

if ( (navigator.userAgent.indexOf('iPad') != -1)) {document.location = "index_ipad.html";}

有人可以让我知道如何做到这一点吗?

暂无
暂无

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

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