I've been looking all over for a solution to this so hopefully somebody can point me in the right direction.
I need to check whether the browser is IE or Firefox, then call a javascript file depending on which browser it is.
Here's what I have so far, but it's not executing the script:
PHP Code:
<script type="text/javascript"> function getInternetExplorerVersion() // Returns the version of Internet Explorer or a - 1 // (indicating the use of another browser). { var rv = - 1; // Return value assumes failure. if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } return rv; } function checkVersion() {
var ver = getInternetExplorerVersion();
if ( ver > - 1 ) { if ( ver < 8.0 ) document.write('<scr' + 'ipt type="text/javascript" src="ie.js"></script>');
} else if((navigator.userAgent.indexOf("Firefox") != - 1)) { document.write('<scr' + 'ipt type="text/javascript" src="ff.js"></script>');
}
} </script>
Anybody have a solution for this? Thanks
|