Friday, June 26, 2009

How to detect browser using JavaScript

var isIE = false; var isFF = false; var isOP = false; var isSafari = false; function DetectBrowser() { var val = navigator.userAgent.toLowerCase(); if(val.indexOf("firefox") > -1) { isFF = true; } else if(val.indexOf("opera") > -1) { isOP = true; } else if(val.indexOf("msie") > -1) { isIE = true; } else if(val.indexOf("safari") > -1) { isIE = true; } }

No comments:

Post a Comment