aslum
aslum

Reputation: 12254

What am I doing to make IE angry?

So I added a little bit of jQuery and now IE crashes pretty hard when I try to load my page. Other browsers seem fine. IE behaves much in the same manner as when I've accidentally created an infinite loop in the past, but since it's not causing problems for other browsers I'm a little confused as to what the actual cause is.

$(window).resize(function(){
sizeOfResize = $('#main').width()*.9;
$('#news p').width(sizeOfResize);   
})

Upvotes: 2

Views: 314

Answers (2)

Francis Lewis
Francis Lewis

Reputation: 8980

2 things I noticed - which may or may not be the case. As we all commented, IE gets angry without you having to do much.

Anyways, to the point. In your example code, you don't have a semi-colon at the end of the function. I don't know if that would cause IE to be angry or not, but it's worth a try. IE is very touchy about commas and semi-colons and not in the least forgiving like the other browsers.

If the above doesn't work, see if it will take a number other than .9 - maybe try a whole number. I'm thinking it may not like the . in the .9 - if that's the case, you'll have to change how you do the math.

Upvotes: 3

Nick
Nick

Reputation: 1272

Not a direct answer, but usually the way I test my code is to start with simple alerts and get more complex. for example, try starting with this code:

$(window).resize(function(){
     alert("TEST");   
})

If that doesn't break it, then add the next part of your original sample:

 $(window).resize(function(){
sizeOfResize = $('#main').width()*.9;
alert("TEST");   
})

And if that doesn't break it, add the last bit:

$(window).resize(function(){
sizeOfResize = $('#main').width()*.9;
$('#news p').width(sizeOfResize);  
   alert("test"); 
})

This won't fix your problem, but it should point to the specific line of code that is breaking it.

Here is a similar question and answer as well:

Cross-browser window resize event - JavaScript / jQuery

Hope that helps

Upvotes: 1

Related Questions