views:

2184

answers:

6

I'm getting the following error in IE 6:

Line: 454  
Char: 13  
Error: Invalid Argument  
Code: 0  
URL: xxxxx/Iframe1.aspx

and I can't for the life of me find what's causing this.

This only happens in a situation where I have a main page that has several IFrames, and it only happens when I have one particular IFrame (the one pointed to by the URL in the error message), and that IFrame is invisible at the time of loading.
I've narrowed it up to there, but I still can't find anything more specific...

The IFrame in question doesn't have 454 lines in its HTML, nor do any of the JS files referred by it.

I tried attaching VS to iexplore.exe as a debugger, and it breaks when the error occurs, but then tells me "There is no source code available for the current location"...

Any suggestions on how I can go about chasing this one?


UPDATE: I found this problem through brute-force, basically, commenting everything out and uncommenting randomly...
But the question still stands: what is the rational way to find where the error is, when IE reports the wrong line number / file?

+1  A: 

It's virtually impossible to debug this without a live example, but one thing that often causes an "Invalid Argument" error in Internet Explorer is trying to set an incorrect value for a style property.

So something like:

document.getElementById("foo").style.borderWidth = bar + "px";

when "bar" has the value null, or undefined, or is the string "grandma", will cause it, as "grandmapx" isn't a valid value for the borderWidth style property.

NickFitz
Thanks. I actually looked into all places where I'm manipulating style and commented those out.I'm actually looking for pointers to what I can do when IE reports an error in a line number that doesn't exist. Any ideas?
Daniel Magliola
The ways of IE are strange, and are not to be understood by we mere mortals ;-) I'd advise trying it in Firefox, Safari, Chrome or Opera and seeing if they can give you a better indication of exactly where the error is happening. IE is notorious for generating meaningless line numbers, unfortunately.
NickFitz
+3  A: 

IE's Javascript engine is disgusting when it comes to debugging. You can try enabling script debugging in the Advanced Options, and then if you have Visual Studio installed it will jump to the place of error... if you're lucky. Other times you don't get anything, especially if the code was eval()'ed.

Another thing about these line numbers is that it doesn't reflect which file the error is happening in. I've had cases where the line number was actually correct, but it was in a linked .js file, not the main file.

Vilx-
A: 

I run into this problem a lot too, and I've also resorted to commenting everything out until I find the problem. One thing that I find to be useful is to add a try/catch block to every javascript method. Sometimes I add an alert to tell what method the error came from. Still tedious, but easier than trial and error commenting. And if you add them every time you write a new method it saves a lot of time in the event errors like those occur.

function TestMethod()
{
    try
    {
        //whatever
    }
    catch (ex)
    {
        ShowError(ex.description);
        //alert("TestMethod");
    }
}
tessa
+2  A: 

Try using the Microsoft Script Debugger or DebugBar (http://www.debugbar.com) which may give you some better IE6 debugging tools. They always help me with IE6.

Also, does this happen in any newer versions of IE or just in IE6?

Bryan Migliorisi
A: 

In IE 8 and I believe 7, just hit F12 to launch the debugging environment which is nearly identical to Firebug.

tkamil
"nearly identical"... haha... not even close
Homer6
A: 

Another possibility:

I do a lot of dev between two computers, at home and at work, so I often email myself or download pages from the server to work on. Recently I realised that Vista has a habit of unilaterally applying blocks to certain files when they are downloaded in certain ways, without notifying me that it is doing this.

The result is that, for example, an HTML page wants to access the .js file in its header, but it doesn't have permission to access local files. In this case, it doesn't matter what you write in the .js file, the browser will never even read it, and an irksome Line: 0 error will result.

So before you comb your code for an error, check your HTML page's properties, and see if it hasn't been blocked by the OS....

Vid