Why my JavaScript is not executed correctly?help

Asked By 90 points N/A Posted on -
qa-featured

Hi guys, I'm getting errors to while executing Java script though all the script is error free I checked it again and again and also when I try to see that the program is working correctly using Internet explorer its not working at all what might be the problem.Please help me solve this.Thanks in advance

SHARE
Answered By 590495 points N/A #181064

Why my JavaScript is not executed correctly?help

qa-featured

Though the use of JavaScript is supported on all web browsers including Microsoft Internet Explorer, things are really different when you run it on Microsoft Internet Explorer. That’s why websites create a separate CSS file for Microsoft Internet Explorer to adjust how the page displays and to make sure it displays correctly on the web browser.

This line, for example:

  • <!–[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]–>

If you have this on your webpage and the page detects Microsoft Internet Explorer 6 then style.ie6.css is used instead of the default CSS file. But if a different version of Microsoft Internet Explorer is detected this line will not be activated. Since there is no HTML tag that can be used in JavaScript for detecting and classifying web browser versions, you can use the Navigator object in JavaScript to check the version number of the web browser.

To check for the version information of the web browser, you can use “navigator.appVersion”. For example, the line “document.write('Browser Version: '+navigator.appVersion)” may display the information:

  • Browser Version: 5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36 OPR/24.0.1558.53

You can then create a JavaScript that will extract and cut only the version number of the browser instead of displaying the entire version and then use it to direct a certain version of Microsoft Internet Explorer to a specific JavaScript file. If you do this, you can fully customize your page when it is displayed in Microsoft Internet Explorer. To learn the different properties you can use with the navigator object, visit The Navigator Object.

Related Questions