Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yoga99

macrumors newbie
Original poster
Jul 20, 2005
6
0
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

macrumors 65816
Oct 9, 2002
1,494
0
:noitаɔo˩
This should work :)

Code:
<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)
 

Lacero

macrumors 604
Jan 20, 2005
6,637
3
ChicoWeb said:
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

Moderator emeritus
Oct 5, 2001
11,219
2
San Diego, CA
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

macrumors newbie
Original poster
Jul 20, 2005
6
0
is the linux redirecting a must?

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

macrumors 65816
Oct 9, 2002
1,494
0
:noitаɔo˩
yoga99 said:
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:

Code:
<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

macrumors 6502a
May 2, 2005
767
0
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

macrumors 68020
Sep 3, 2003
2,284
0
Alta, Norway
yoga99 said:
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

macrumors newbie
Original poster
Jul 20, 2005
6
0
i got it...

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

macrumors 65816
Nov 7, 2004
1,245
57
Houston, USA
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.