'Invalid Argument' Error in IE, in a line number that doesn't exist

debugging, internet-explorer, javascript

Solution

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.

Problem

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?

Original source