[thelist] javascript syntax

Liorean Liorean at user.bip.net
Sat May 11 02:01:01 CDT 2002


At 20:51 2002-05-09 +0100, dn at dittodesign.co.uk wrote:
> >a regular expression search on the navigator.platform.
>er ?
>
>one common to all macs ?
>what would that be?

Try using:
rd=/mac/i.test(navigator.platform)&&(top.location='ns/index.htm');

If checks for any occurrence of the case insensitive text 'mac' in
navigator.platform and if it exists changes the location string. If if
doesn't exist, the AND (&&) works like a conditional short-circuiting and
location isn't changed.

I'd also rethink the url. Some browsers use the relative url as root
relative, some use if from the current path, and some doesn't expand it at
all. I'd use an absolute url instead.

// Liorean




More information about the thelist mailing list