View Full Version : Explorer Error with Javascript Arrays
sniperman
07-13-2009, 11:24 AM
Can anyone tell me why Firefox treats this Javascript code normally while IE gives me an error: Object doesn't support this property or method???
Are arrays another IE quirk because the whole script (very large) works perfectly in other browsers.
position = new Array (10);
position[0] = "DC";
position[1] = "DL";
position[2] = "DR";
position[3] = "MC";
position[4] = "ML";
position[5] = "MR";
position[6] = "FC";
position[7] = "FL";
position[8] = "FR";
position[9] = "ST";
I can only guess it has something to do with syntax
vwphillips
07-13-2009, 11:32 AM
<script type="text/javascript">
/*<![CDATA[*/
position = new Array(10);// not new Array (10);
position[0] = "DC";
position[1] = "DL";
position[2] = "DR";
position[3] = "MC";
position[4] = "ML";
position[5] = "MR";
position[6] = "FC";
position[7] = "FL";
position[8] = "FR";
position[9] = "ST";
alert(position)
/*]]>*/
</script>
sniperman
07-13-2009, 12:18 PM
thanks, but that didn't quite work. I have 600 lines of code so IE must have picked up some routine connected to new Array that does not work on IE. :mad:
I'll have to debug
Can anyone recommend a javascript debugger for IE??
sniperman
07-14-2009, 08:56 AM
Thought I should note I resolved the initial problem by declaring the variable like so... despite its declaration in the script body
var position = new Array (10);
position[0] = "DC";
position[1] = "DL";
position[2] = "DR";
position[3] = "MC";
position[4] = "ML";
position[5] = "MR";
position[6] = "FC";
position[7] = "FL";
position[8] = "FR";
position[9] = "ST";
This seems to do the trick in IE7 browsers. I did a thorough check across boards and forums to find heaps of people have issues with Arrays in IE7.
The modified script now throws up another problem later in the script
ERROR: Out of memory
My script does use a lot of RECURSION due to loop states until a random number fulfills a certain condition.
Before I develop a workaround, does anyone know why IE7 uses such a small memory cache and workarounds you could share... Thnx
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.