Wednesday, July 22, 2009

JavaScript: browser type and version detection

To check for a specific browser type and version and display a popup, include below code in HTML page:

<script>
if (navigator.userAgent.toLowerCase().match("safari") && navigator.userAgent.toLowerCase().match("version/4")) {
window.alert("Detected Safari 4 browser!!");
}
</script>