views:

72

answers:

2

Hi,

The following code works in all browsers apart from IE6...

var mylib =
{
    selectStyle :
    {
        init : function()
        {
            $('#select-box1').jqTransform({imgPath:'jqtransformplugin/img/'});
        }
    }
}

<script type="text/javascript">
mylib.selectStyle.init();
</script>

The error states 'mylib' is undefined

Can someone please help otherwise I will have to spend alot of time redoing a lot more code than this.

Many thanks, C

+3  A: 

Add a semicolon at the end of the definition of mylib.

var mylib = { ... };

When declaring anything in var something = ...; always add a semicolon at the end.

Thank you IE, you are so wonderful, reminding us to put semicolons. (Sarcasm? maybe...)

Edit: The semicolon is not a recommendation, IE considers it an error if you don't put it after closing curly brackets, so if you declare a function in a var, put the semicolon too.

var myFunc = function(){ .... };.

But if you declare a function in the namespace, you don't need to add the semicolon.

function doSomething(){ ... } <-- no semicolon.

UberNeet
+1  A: 

Hello,

IE6 is no longer relevant - please do not give him air more details + solution here : http://ie6update.com/

ofir
I agree with the movement, but your website should support the browser of your users. What if you are making a Internal Site for your company, and the 300 computers in the company still use IE6? You should consider all browsers if you think yourself as a serious webdev. I fixed an IE6 issue couple months back because a good client (Lawfirm) was still using IE6.
UberNeet
I wouldn't work for a company that forces their employees to use browsers that are a decade old. This is a good solution to stubborn clients using IE6: http://plugins.jquery.com/project/crash . Actually, that, or ActiveX viruses.
Matti Virkkunen
LOL, that will definitely solve the problem, my client will run to the IE6 safe competitors website.
UberNeet