Search code examples
javascriptinternet-explorer-6

IE6 Script Tag error


I've never seen this error. We have some clients that use Internet Explorer 6, so we need some pages to work on it.

We have the following HTML code:

<script type="text/javascript">
var bust = 236;
</script>

IE6 is throwing the following error message: 'Undefined' is null or not an object.

Do you have any idea what it might be? Thanks.


Solution

  • It sounds like bust is conflicting with some other global. The global name space is really crowded.

    You may be able to resolve it by wrapping your code in a scoping function so that it's not at global scope anymore:

    <script type="text/javascript">
    (function() {
        var bust = 236;
    })();
    </script>
    

    Or if it has to be a global, try another name until you find one that doesn't cause the problem. Global variables aren't fundamentally broken, even in IE6.