Error "Invalid Argument" in IE, in line number that does not exist

In IE 6, the following error appears:

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

and I can’t find the reason for this for me.

This only happens when I have a main page with multiple IFrames, and this only happens when I have one specific IFrame (the one pointed to by the URL in the error message), and that the IFrame is invisible load time .
I narrowed it down there, but I still can't find anything more specific ...

The IFrame in question does not have 454 lines in its HTML file, and not one of the JS files associated with it.

I tried connecting VS to iexplore.exe as a debugger, and it breaks when an error occurs, but then tells me: "The source code is not available for the current location" ...

Any suggestions on how I can chase this?


UPDATE: I found this problem with brute force, basically by commenting everything 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?

+6
javascript debugging internet-explorer
source share
8 answers

Javascript IE is disgusting when it comes to debugging. You can try to enable script debugging in additional parameters, and then if you have Visual Studio installed, it will move to the place of the error ... if you are lucky. In other cases, you get nothing, especially if the code was eval () 'ed.

Another feature of these line numbers is that it does not reflect in which file the error occurs. I had cases where the line number was really right, but it was in the linked .js file, and not in the main file.

+11
source share

Try using the Microsoft Script DebugBar ( http://www.debugbar.com ), which can give you some improved IE6 debugging tools. They always help me with IE6.

Also, does this happen in any new versions of IE, or only in IE6?

+6
source share

It is practically impossible to debug this without a live example, but one thing that often causes the "Invalid Argument" error in Internet Explorer is trying to set the value for the style property to the wrong value.

So something like:

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

when "bar" is null or undefined, or it is the string "grandma", it will call it, since "grandmapx" is not a valid value for the border's style property.

+5
source share

IE9 has browser mode.

Open the "Developer Tools", then select the version that you want to emulate in the console, reload the error page, and the console will display the line numbers and the correct file, where the error is.

+2
source share

I also run into this problem, and I also resorted to commenting everything until I find the problem. One thing that I find useful is to add a try / catch block to each javascript method. Sometimes I add a warning to let me know which method the error came from. Still tiring, but easier than trying and commenting on errors. And if you add them every time you write a new method, it saves a lot of time in case of such errors.

 function TestMethod() { try { //whatever } catch (ex) { ShowError(ex.description); //alert("TestMethod"); } } 
+1
source share

Note to other readers: I recently had this "Invalid Argument". the error reported in IE7-9 and eventually found that it was the way I used setTimeout / setInterval.

This is not true in IE:

 var Thing = {}; Thing.myFunc = function() { ... }; setTimeout(Thing.myFunc, 1000); 

Instead, wrap the callback in an anonymous function as follows:

 var Thing = {}; Thing.myFunc = function() { ... }; setTimeout(function() { Thing.myFunc(); }, 1000); 

and no more errors of the "wrong argument".

+1
source share

Another possibility:

I do a lot of dev between two computers, at home and at work, so I often email or download pages from the server for work. I recently realized that Vista has the habit of unilaterally applying blocks to certain files when they are downloaded in a certain way, without notifying me that it does.

As a result, for example, an HTML page wants to access the .js file in its header, but it does not have permission to access local files. In this case, it does not matter what you write in the .js file, the browser will never even read it, and an abusive Line: 0 error will occur.

So, before combing your code for errors, check the properties of your HTML page and see if it is blocked by the OS.

0
source share

As NickFitz noted, styling was a problem with my code.

 document.getElementById('sums<%= event.id %>').style.border='1px solid #3b3b3b;' 

I removed the border style and my problems with IE disappeared.

0
source share

All Articles