drstuey
asked on
OS detection script for CSS link tag - is this correct syntax?
a quickie for who ever gets it first:
Is this the correct syntax for conditionally including a link to a mac and PC stylesheet.
<SCRIPT LANGUAGE="JavaScript">
<!--
version = navigator.appVersion;
if (version.toLowerCase().ind exOf("mac" )!=-1) {
document.write('<link rel="STYLESHEET" type="text/css" href="/styles_mac.css">');
}
else {
document.write('<link rel="STYLESHEET" type="text/css" href="/styles.css">');
}
// -->
</script>
Is this the correct syntax for conditionally including a link to a mac and PC stylesheet.
<SCRIPT LANGUAGE="JavaScript">
<!--
version = navigator.appVersion;
if (version.toLowerCase().ind
document.write('<link rel="STYLESHEET" type="text/css" href="/styles_mac.css">');
}
else {
document.write('<link rel="STYLESHEET" type="text/css" href="/styles.css">');
}
// -->
</script>
ASKER
Thanks, I have implemented that, but I won't know if that worked until I run it through Browser Photo tommorrow.
I was hoping for an explanation as well. I was quite happy with the OS detection part of the script, the explanation I read for doing it this way:
version = navigator.appVersion;
if (version.toLowerCase().ind exOf("mac" )!=-1)
seemed entirely reasonable to me. It was as much the syntax of everything else I was concerned about. The version I posted doesn't seem to be doing anything, it seems like both CSS links are visible to all browsers so the Macs see the PC CSS link as well and that overrides the Mac one????
I was hoping for an explanation as well. I was quite happy with the OS detection part of the script, the explanation I read for doing it this way:
version = navigator.appVersion;
if (version.toLowerCase().ind
seemed entirely reasonable to me. It was as much the syntax of everything else I was concerned about. The version I posted doesn't seem to be doing anything, it seems like both CSS links are visible to all browsers so the Macs see the PC CSS link as well and that overrides the Mac one????
it is the wrong property that you are using, to get the Mac platform, it would be safer to use the userAgent property.
ASKER
Thanks, I have implemented that, but I won't know if that worked until I run it through Browser Photo tommorrow.
I was hoping for an explanation as well. I was quite happy with the OS detection part of the script, the explanation I read for doing it this way:
version = navigator.appVersion;
if (version.toLowerCase().ind exOf("mac" )!=-1)
seemed entirely reasonable to me. It was as much the syntax of everything else I was concerned about. The version I posted doesn't seem to be doing anything, it seems like both CSS links are visible to all browsers so the Macs see the PC CSS link as well and that overrides the Mac one????
I was hoping for an explanation as well. I was quite happy with the OS detection part of the script, the explanation I read for doing it this way:
version = navigator.appVersion;
if (version.toLowerCase().ind
seemed entirely reasonable to me. It was as much the syntax of everything else I was concerned about. The version I posted doesn't seem to be doing anything, it seems like both CSS links are visible to all browsers so the Macs see the PC CSS link as well and that overrides the Mac one????
ASKER
ooops, I must have gone back in my browser and reposted my comment
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
points to b1xml2
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
ahosang
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
points to b1xml2
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
ahosang
EE Cleanup Volunteer
ASKER
Naughty me I have been prompted to give the points out.
Yes it works. It was my mistake that I thought it didn't.
cheers
Yes it works. It was my mistake that I thought it didn't.
cheers
document.write('<link rel="STYLESHEET" type="text/css" href="/styles_mac.css">');
} else {
document.write('<link rel="STYLESHEET" type="text/css" href="/styles.css">');
}