I am trying to redirect the Safari browser on Desktop only. 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. On Safari for the iPad and the iPhone, the colors are right, matching Chrome, IE and 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.
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.
You can use navigator.userAgent
to determine the OS as well as browser details.
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
if ( (navigator.userAgent.indexOf('iPad') != -1)) {document.location = "index_ipad.html";}
Can someone let me know how to do this in one?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.