Microsoft Javascript Problems

Internet Explorer has always had a "unique" (not a standards-compliant) way of interpreting JavaScript. As of IE8, most of these issues have been resolved, although there are still a couple of minor quirks. Fortunately, most of them are easily avoided.

  1. <script type="application/javascript">

    • When putting a JavaScript into the head of an HTML document, the code must be surrounded by <script> tags. Most browsers support the value "application/javascript" for the "type" attribute, but IE8 does not. Instead, use "text/javascript" for consistent results across all browsers.

    number.toFixed(0)

    • The number.toFixed(0) method should round to the nearest whole number. IE8 returns unpredictable results. Instead, use Math.round(number), as the result is consistent across all browsers.

    selectElement(newOption, null).add()

    • In most browsers, the value "null" in this line of code adds "newOption" as the last option of a select element. In IE8, it gives the JavaScript error "Invalid Argument." The fix is simply to leave off the "null" argument when scripting specifically for IE8, as follows: selectElement(newOption).add().

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured