View Full Version : Redirecting Mac users
yoga99
Oct 22, 2005, 10:17 AM
hi
I want to direct Mac users who visit my site
to a special Mac-friendly URL.
I found a Javascript that does it well but it forces me
to redirect the Win users too:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
page = ((navigator.platform.indexOf('Win') > -1) ? "winredirect.htm" : "http://www.macredirect.com");
window.location=page;
// End -->
</script>
How do I revise this script so the Win users will remain
in the page where this script is (index.htm) and won't
be redirected while the Mac users will be redirected?
If I replace the winredirect.htm with index.htm or
http://www.mysitename.com
It doesn't work and the page doesn't load.
So how do I redirect only the Mac users???
Thanks for your time... :-)
Yoga
whocares
Oct 22, 2005, 10:40 AM
This should work :)
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (navigator.platform.indexOf('Win') == -1)
window.location=('http://www.macredirect.com');
// End -->
</script>
Il will redirect all OS that arn't Windows (ie Mac OS, Linux, Unix, etc)
ChicoWeb
Oct 22, 2005, 12:36 PM
Why not just make it viewable by all.
yoga99
Oct 22, 2005, 07:14 PM
It works!!! :-)
Lacero
Oct 22, 2005, 08:51 PM
Why not just make it viewable by all.
I like to redirect Mac users as well, because I have different media video files that sometimes don't work for PC users.
Rower_CPU
Oct 23, 2005, 01:54 AM
I have to also state for the record that redirecting in general is frowned upon. There are lots of reasons, ranging from your browser sniffer not working correctly and preventing people from accessing content that they should be able to, to maintaining separate version of the content which means more work.
yoga99
Oct 23, 2005, 11:44 AM
Is there a way to prevent redirecting the Linux users so that the Linux folks will stay at the default page together with the windowz users?
whocares
Oct 23, 2005, 03:56 PM
Is there a way to prevent redirecting the Linux users so that the Linux folks will stay at the default page together with the windowz users?
Yes. Try:
<script language="JavaScript">
<!--
if (navigator.platform.indexOf('Mac') > -1)
window.location=('http://www.macredirect.com');
//-->
Or something like that I guess...
(I agree with fellow posters advising you against redirecting)
ZoomZoomZoom
Oct 23, 2005, 04:54 PM
wow, big props on this. i was thinking of doing something like this for my website, but had forgotten about it. (and didn't know how to do it anyways)
dubbz
Oct 23, 2005, 05:01 PM
Is there a way to prevent redirecting the Linux users so that the Linux folks will stay at the default page together with the windowz users?
It offends me that you are going to group us with the Windows users. :p
I'm also a bit curious why you're doing this at all. I can't think of any good reason why.
yoga99
Oct 23, 2005, 08:04 PM
whocares, your new code didn't work but I manged to fix it (based on your prev. code) -
Thanks!!!!! Here is the correct code:
<script language="JavaScript">
<!--
if (navigator.platform.indexOf('Mac') > -1)
window.location=('http://www.macredirect.com');
// End -->
</script>
As to why i'm doing it - i just want to give the mac
users a mac friendly page, maybe it's a mistake but i just wanna test it..
jaseone
Oct 24, 2005, 11:41 PM
Define Mac friendly in a web page context for me please?
What are you going to do different? If you code with standards in mind and are aware of a few quirks here and there with MSIE then your site look identical in all the major browsers and degrade well to the older browsers as well. If you are linking to things like movies that are for some reason encoded differently for different platforms then just provide alternate links with appropriate icons.
Browser sniffing is just wrong and an excuse for people that don't want to make their site work as it should...
I might just have to visit your site from my Linux laptop and set my User Agent so your site thinks I'm a Mac just to spite you. :P
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.