nd3_2000 Posted August 27, 2009 Share Posted August 27, 2009 Hi Guys... I need to use a browser detector function so depending on which browser is being used changes whilch javascript file I use for posotiong of a drop down box.... Am having problems getting the code right..... this is what I have <script type="text/javascript"> if (navigator.userAgent.indexOf("Firefox")!=-1) document.write("U r using Firefox") if (navigator.userAgent.indexOf("MSIE")!=-1) document.write("u r using IE") </script> THis is working fine and detects either browser BUT I need to add somewhere to use the different jsfile, which ioriginall looks like this <SCRIPT TYPE="text/javascript" SRC="/menu/menu_data2.js"></SCRIPT> So if its IE I want it to use the above file if its FF I want it to use <SCRIPT TYPE="text/javascript" SRC="/menu/menu_data.js"></SCRIPT> Can anyone help scritp this as I keep getting a blank form Quote Link to comment Share on other sites More sharing options...
haku Posted August 28, 2009 Share Posted August 28, 2009 Is your problem an IE problem? If so you are better off using conditional comments to fix this, as some users will have javascript turned off. And even if it's not an IE problem and your problem is somewhere else, javascript isn't a good way to fix it. Validating your code is a good place to start. Then make sure your code works in FF or Safari, or some other non-IE browser. From there you can use conditional comments to make it work in IE if necessary. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.