/    Sign up×
Community /Pin to ProfileBookmark

Opera for Mac Unwanted Browser detect/redirect

I hunted around and this script (from an earlier post in this forum and I’m sorry I don’t recall the authors name because it is a nice piece of work) works a treat for detecting and redirecting.

[CODE]<script language=javascript>
var agt=navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf(“mac”)!=-1);
var version = parseInt(navigator.appVersion);
var is_ie = (agt.indexOf(“msie”)!= -1);
var is_ie5 = (is_ie && (version = 5));
if (is_mac && is_ie5) {location.replace(“mac.html”)}
</script>[/CODE]

It will redirect ie for mac which is great and it will not redirect safari for mac which is also great.Unfortunately it detects opera 8.54 for mac as a mac and redirects it which I don’t want to happen.

All I want to do is redirect ie for mac users (I know this is a rare configuration but it makes up a significant proportion of the site users).

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallJun 07.2006 — The userAgent field contains whatever the browser puts there and many browsers give the user a choice of values or even let them enter their own. Therefore you can't rely on a particular value in that field meaning that it is a particular browser. Anyway browsr detection was the 19th century way of doing things. In the 21st century the idea is to use feature detection. Test whether the browser supports the feature that you want to use before using it instead of testing the browser because the next version of the particular browser will probably support the feature even if the current version doesn't.

If you need to test specifically for IE you can use conditionals in the HTML

<!--[if IE]>IE only code goes here<[endif]-->

There hasn't been a version of IE for the Mac since 2003 when Microsoft killed it.
Copy linkTweet thisAlerts:
@qasabahauthorJun 07.2006 — Unfortunately I'm surrounded by macs running ie and they can't display (or I don't know how to make it deal with) a liquid css controlled page correctly. It is only for personal use, a World Cup Soccer Pool, so I don't need a super slick way to deal with it just one that works.

I was just curious to know if there was a way to single out opera in the same fashion.
×

Success!

Help @qasabah spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...