PDA

View Full Version : IE is complaining and I can't figure out why.



???
03-24-2009, 03:59 PM
If you want all of my code, it's at http://subatomicfusion.webs.com/js/test.htm. From there, there is an external Javascript file at http://subatomicfusion.webs.com/js/SOM/Element.js. In Firefox and Safari, my test.htm should be a rectangle with some colors and a box with text in it, and the whole thing should have a Picachu cursor. In IE this doesn't happen. It complains about an "Invalid Argument." at line 137, char 3, and this is on my Element.js file. The code around there is as follows, starting with line 135 and ending with 138 (137 is the }; one):

private.setStyle = function (name,value) {
private.element.style [name] = value;
};
//Methods
If I comment out private.element.style [name] = value;, there are no errors except that all the colors are based on styles so half my stuff doesn't show up. Could someone tell me why IE told me the wrong line number, and what the problem really is? It would be greatly appreciated.

Thanks,
Stephen

jscheuer1
03-25-2009, 01:31 AM
If it is that line, that means that:


private.element.style [name] = value;

or something about it or the entire function is the real problem, so I would try getting rid of the non-standard space in its syntax, ex:


private.element.style[name] = value;

If that doesn't get it, another thing to try is to make sure that all arguments fed to this:


private.setStyle = function (name,value)

are valid style property/value pairs in IE. Other browsers may have an error here but not make a big issue over or halt processing on it, IE can be finicky in this area.

Also make sure (via temporary alerts or whatever inserted into your code) that private means the same thing in IE here as it does in the browsers that this code is working with.

Generally though, and if none of this helps, to be sure of getting an accurate error line number (+- 1) in IE, all scripts must be on the page. Temporarily make all scripts on page scripts, rather than external in order to diagnose this properly.

Also, both private and public are reserved words, it would be best to use others, like:

myprivate

mypublic

???
03-28-2009, 03:26 AM
Thanks for the suggestions. It turned out that IE freaked out when something tried to set a height/width of "NaNpx".

jscheuer1
03-28-2009, 05:34 AM
That would fall into the category of:


. . . make sure that all arguments fed to this:


private.setStyle = function (name,value)

are valid style property/value pairs in IE.

And, as I'm pretty sure, if that's the problem, you would be able to do a (at some point in the code):


if (!isNaN whatever)
something that uses the number

or something similar.