简体   繁体   English

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

[英]Redirect Safari Browser on a Desktop only

I am trying to redirect the Safari browser on Desktop only. 我试图仅在桌面上重定向Safari浏览器。 I have a video in the header that the background color matches the header background. 标题中有一个视频,其中背景颜色与标题背景匹配。 The problem is Safari on OS X is showing the colors differently. 问题是OS X上的Safari显示颜色不同。 On Safari for the iPad and the iPhone, the colors are right, matching Chrome, IE and Firefox. 在iPad和iPhone的Safari上,颜色正确,与Chrome,IE和Firefox匹配。 So I made a different color background to match the video for Safari desktop only, but when I redirect the browser for Safari, it also redirects the iPad and iPhone which then shows a color issue. 因此,我设置了不同的颜色背景来仅与Safari桌面上的视频匹配,但是当我将浏览器重定向到Safari时,它也重定向了iPad和iPhone,这随后显示了颜色问题。

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

Any advise to only target Safari on the desktop and allowing the Safari browser on ios to stay on that page would be greatly appreciated. 任何建议只针对桌面上的Safari并允许ios上的Safari浏览器停留在该页面上的建议,将不胜感激。

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

You can use navigator.userAgent to determine the OS as well as browser details. 您可以使用navigator.userAgent确定操作系统以及浏览器详细信息。

use class based on this value. 根据此值使用类。

I cannot seem to get it to do this in one script, which I would love to. 我似乎无法在一个脚本中做到这一点,我很想这样做。

First redirect 第一次重定向

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

Then a replicated page of the index to get back if an ipad 然后返回索引的复制页面,以获取ipad

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

Can someone let me know how to do this in one? 有人可以让我知道如何做到这一点吗?

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

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