[X]

Browser Detection

browser tricks 1997 partly

Works out which browser the visitor has, so you can serve them the right page.

In 2026: The properties still exist but every browser now lies in its user agent string precisely because of scripts like this. Test for the feature you need instead.

Where it came from: Netscape JavaScript navigator object, 1996. This script is the reason every user agent string now lies about itself. MDN

<script language="JavaScript">
var isNS = (navigator.appName === "Netscape");
var isIE = (navigator.appName.indexOf("Microsoft") !== -1);
var ver  = parseInt(navigator.appVersion, 10);

document.write("You are using " + navigator.appName
             + " version " + navigator.appVersion + "<br>");

if (isIE && ver >= 4)      document.write("Loading the IE4 version...");
else if (isNS && ver >= 4) document.write("Loading the Netscape 4 version...");
else                       document.write("Loading the plain HTML version...");
</script>

<!-- What to do in 2026: test the capability, not the name -->
<script>
if (window.IntersectionObserver) { /* modern path */ }
else { /* fallback path */ }
</script>
sandboxed demo · breaks nothing but itselfrestart

More in browser tricks

all 25 in browser tricks › · the whole library ›