Home » Support » Help Articles » Fixing CSS and JavaScript Bugs in Internet Explorer

Fixing CSS and JavaScript Bugs in Internet Explorer

Back to Help Articles Home


As many users around the globe are still using Internet Explorer (IE), as a developer we need to deal with the bugs of IE. Certainly IE 6 has been the nightmare of many designers, IE 7 looks better but still had some problems, IE 8 was better still, and IE 9 is certainly much better, but to the extent that you care about supporting older versions of IE. You may face design problems that you need to solve so this article is intended to give some advice. We typically use IE conditional comments to fix the IE issues.

This guide will walk you through fixing CSS and JavaScript bugs in IE.

Fixing CSS Bugs

  1. While creating a design or template for a website you should design the same in Firefox or in Chrome. Once the design is completed look for the problems in different versions of IE because IE is the least standards compliant browser. The issues can be fixed by using IE Specific CSS files that do not affect other browsers.
  2. The IE conditional comments can be used in the head section of html page to fix the issues in IE.

    This example only affects IE 6

    <!--[if lt IE 7]>
    <link rel="stylesheet" href="style-ie6.css" type="text/css"/>
    <![endif]-->

    This example only affects IE 7

    <!--[if IE 7]>
    <link rel="stylesheet" href="/style-ie7.css" type="text/css" />
    <![endif]-->

    This example affects any version of IE

    <!--[if IE]>
    css codes can be written here
    .container{float:left;width:100%;}
    <![endif]-->

Fixing JavaScript Bugs

Normally IE gives the following javascript error when a HTML page loads.

Figure One

The following error appears in the page because of following reasons

  1. If the <script> block is not written properly.

    For Ex.

    <script type="application/javascript">//Wrong. This will give error.
    Solution:<script type="text/javascript">// Correct

  2. When a JavaScript function is called in onload function but the function is not written in any part of the page.

    For Ex.

    <body onload="init();"If the init function is not written in any part of the page then it will give an error.
    Solution: Remove the JavaScript event and the function.

You are done with.



Updated on Nov 11, 2015

The techReview is an online magazine by Batoi and publishes articles on current trends in technologies across different industry verticals and areas of research. The objective of the online magazine to provide an insight into cutting-edge technologies in their evolution from labs to market.

Visit techReview


English - IN (USD)
New Users? Signup.     Existing Users? Login.