Edit Code in left box and click Show Results button to see the result. | Home
<html> <!-- Mirrored from www.tutorialspoint.com/cgi-bin/practice.cgi?file=javascript_49 by HTTrack Website Copier/3.x [XR&CO'2010], Thu, 01 Sep 2011 09:09:58 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> <head> <title>Browser Detection Example</title> </head> <body> <script type="text/javascript"> <!-- var userAgent = navigator.userAgent; var opera = (userAgent.indexOf('Opera') != -1); var ie = (userAgent.indexOf('MSIE') != -1); var gecko = (userAgent.indexOf('Gecko') != -1); var netscape = (userAgent.indexOf('Mozilla') != -1); var version = navigator.appVersion; if (opera){ document.write("Opera based browser"); // Keep your opera specific URL here. }else if (gecko){ document.write("Mozilla based browser"); // Keep your gecko specific URL here. }else if (ie){ document.write("IE based browser"); // Keep your IE specific URL here. }else if (netscape){ document.write("Netscape based browser"); // Keep your Netscape specific URL here. }else{ document.write("Unknown browser"); } // You can include version to along with any above condition. document.write("<br /> Browser version info : " + version ); //--> </script> </body> <!-- Mirrored from www.tutorialspoint.com/cgi-bin/practice.cgi?file=javascript_49 by HTTrack Website Copier/3.x [XR&CO'2010], Thu, 01 Sep 2011 09:09:58 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> </html> |