Discussion Locked

Identifing browsers

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
What would be the code needed to identify what browser is using your site and should this be in a function that is activated on an onLoad()?

1 reply

by jay eckles

You want to inspect the navigator object, specifically the userAgent and appVersion properties.

Whether you call the function from the onLoad event depends on what you're doing. If the HTML you render is dependent upon the browser version, then onLoad is a bit too late. I'd define the function in the HEAD, then call the function immediately after its declaration. You can then use the result in the BODY as it is being dowloaded and rendered.

By the way, do a Google search on "browser sniffing". The first hit is a really good explanation of sniffing and a really good script.

This discussion is closed to new replies.