[thelist] Browser Sniffing
Ben Henick
persist1 at io.com
Wed Jan 23 13:42:40 CST 2002
On Wed, 23 Jan 2002, Bill Bejeck wrote:
> On my web site, I use "browser sniffing" code (in JavaScript) to direct
> users depending on browser type and version. Instead of redirection, I would
> like to download the appropriate JS and CSS files after detecting the
> browser version and type, and keep the user at the main index page. If this
> possible can anyone suggest where I could find some hints as to how to write
> the code?
Brute force, backwards-compatible:
if (is_supported_client) {
document.write(// appropriate HTML here //) }
W3C DOM:
if (is_supported_client) {
DocHead = document.getElementsByTagName("HEAD");
ExternalFile = createElement("SCRIPT");
ExternalFile.attributes.type = "text/javascript";
ExternalFile.attributes.src = "your_js_file.js";
DocHead.appendChild(ExternalFile); }
When dealing with a stylesheet, you would create a LINK tag, and reference
attributes appropriate to it, instead.
HTH
--
Ben Henick
Web Author At-Large Managing Editor
http://www.io.com/persist1/ http://www.digital-web.com/
persist1 at io.com bmh at digital-web.com
--
"Are you pondering what I'm pondering, Pinky?"
"I think so, Brain, but... (snort) no, no, it's too stupid."
"We will disguise ourselves as a cow."
"Oh!" (giggles) "That was it exactly!"
More information about the thelist
mailing list