devxlogo

JavaScript Browser Detection

JavaScript Browser Detection

Question:
When loading a web page, I need to have JavaScript look at the browser it is loading into, and if it is not version 5 (Internet Explorer 5), I want it to load a gif image within the web page. If it is loading into a browser that is version 5 then, I want a flash swf file to load instead of the gif image.

Answer:
Just put the following code into the BODY section of your page:

MSIE 5 claims to have an application version of 4, but it also includes a comment inside the appVersion field that contains the actual version number. If you search on that field for “MSIE 5” and find it, you’ll know that you have the right browser.

See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist