0

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, I.E. 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.

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

Webedelic
  • 11
  • 1
  • this is a very random thing to do. buut anyways you could add another condition to avoid mobile devices. Have a look at this post: https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser – Sergio Alen Oct 10 '17 at 05:56

2 Answers2

0

You can use navigator.userAgent to determine the OS as well as browser details.

use class based on this value.

Tapas
  • 1,123
  • 8
  • 16
0

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?

Webedelic
  • 11
  • 1