Help with cross-platform javascript css sniffer
Nate Russell
nate at int-res.com
Tue Dec 10 03:20:14 PST 2002
Hello,
I was wondering if someone could point me to what I'm doing wrong.
I'm trying to put a javascript browser sniffer into the pageHeader in
the #prefs section, that will detect PC, Mac or ie3 and load a
separate stylesheet for each result. I have the script below in the
pageheader outline but can't get the css.files to be called up
properly. I keep getting the error: Macro error: Can't evaluate the
expression because the name "ie3" hasn't been defined.
There is probably a problem between the javascript and userscript
getting garbled. It looks as if frontier doesn't recognize my
stylesheets that I saved as outlines in the #styleSheets directory.
Any ideas?
Thanks, nate
<html>
<head>
<title>{title}</title>
{metaTags ()}
<script>
if (navigator.appName == "Microsoft Internet Explorer") \{
if (navigator.appVersion \< 4) \{
document.write({linkStyleSheet (ie3)}
}
}
else if (navigator.appVersion.indexOf("Mac") != -1) \{
document.write({linkStyleSheet (mac)})
}
else \{
document.write({linkStyleSheet (pc)})
}
</script>
</head>
{bodyTag ()}
When the page loads in a browser i get this in the source code:
<script>
if (navigator.appName == "Microsoft Internet
Explorer") {
if (navigator.appVersion < 4) {
document.write(<b>[</b>Macro
error: Can't evaluate the expression because the name "ie3" hasn't
been defined.<b>]</b>
}
}
else if (navigator.appVersion.indexOf("Mac") != -1) {
document.write(<b>[</b>Macro error:
Can't evaluate the expression because the name "mac" hasn't been
defined.<b>]</b>
)
}
else {
document.write(<b>[</b>Macro error:
Can't link to style sheet ":" because it wasn't found.<b>]</b>
)
}
</script>
--
Nate Russell, Webmaster
Inter-Research Science Publisher
Nordbuente 23
D-21385 Oldendorf/Luhe
Germany
Tel: (+49) (4132) 7127 Email: nate at int-res.com
Fax: (+49) (4132) 8883 http://www.int-res.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.userland.com/pipermail/frontier-users/attachments/20021210/d56cc04f/attachment-0002.htm
More information about the Frontier-Users
mailing list