Invalid Argument in Internet Explorer
When viewing a site I am working on in any version of IE, I get a done with errors message and the only thing that seems to load is the background. Really not sure how to g开发者_高级运维o about fixing this one, I am not even sure what the error means.
The error is an invalid argument on line 117.
It works fine in Firefox, Safari, and Chrome.
Here is the URL: http://streamlinehome.com/wordpress/
117 points to the jQuery file. Debugging the code the error occurs in if(e)f[b]=d;
- b is "width"
- d is "NaNem"
Stepping back on the CallStack you are calling the jQuery method here
line 63 in supersubs.js:
$ul.css('width',emWidth);
Looking up a few lines you see a comment about clientWidth and that is probably where the troubles begin. :)
var emWidth = $ul.add($LIs).add($As).css({
'float' : 'none',
'width' : 'auto'
})
// this ul will now be shrink-wrapped to longest li due to position:absolute
// so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
.end().end()[0].clientWidth / fontsize;
// add more width to ensure lines don't turn over at certain sizes in various browsers
So looking at it some more the line ...end()[0].clientWidth returns 0 and fontsize = 0 so you have 0/0 which is NaN
I can't provide a complete answer to your question but I can show you why you are getting an 'Invalid argument' error.
In short, IE is trying to set the width of an element to "NaNem"
. Attempting to do this will cause IE to generate an "Invalid argument" error.
But why is IE trying to set the width of this element to this nonsensical value? This width first appears in a function within the supersubs plugin. The following code attempts to find the width of an em-dash in the current font ($$
contains a <ul>
element):
var fontsize = $('<li id="menu-fontsize">—</li>').css({
'padding' : 0,
'position' : 'absolute',
'top' : '-999em',
'width' : 'auto'
}).appendTo($$).width(); //clientWidth is faster, but was incorrect here
However, IE calculates fontsize
as 0.
Later on, the value of this variable is used:
var emWidth = $ul.add($LIs).add($As).css({
'float' : 'none',
'width' : 'auto'
})
// this ul will now be shrink-wrapped to longest li due to position:absolute
// so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
.end().end()[0].clientWidth / fontsize;
It seems clientWidth
here is also 0, and so this gives emWidth
the value NaN
.
Finally, the following adds an 'em' unit to emWidth
(hence NaNem
) and attempts to set the width of a <ul>
to "NaNem"
. IE isn't having this and gives you the 'Invalid argument' error:
emWidth += 'em';
// set ul to width in ems
$ul.css('width',emWidth);
However, I'm afraid I cannot say why IE is returning 0 for fontsize
. I'd hazard a guess at a potential bug in the supersubs plugin - perhaps it would be worth asking about this on the jQuery forums, or, as the supersubs plugin itself suggests, the jQuery Google Group?
It seems to be an Internet Explorer 32 bit issue running on 64 bit OS. Trying to run IE 64 bit it does not happen.
Try putting a '' around the file name.
#header {
background-image: url(images/header-plain.png);
}
w3schools' example shows a quoted file name: http://www.w3schools.com/css/pr_background-image.asp
精彩评论