Results 1 to 4 of 4

Thread: Explorer Error with Javascript Arrays

  1. #1
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    118
    Thanks
    16
    Thanked 1 Time in 1 Post

    Default Explorer Error with Javascript Arrays

    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.

    Code:
    	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

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <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>

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    sniperman (07-13-2009)

  4. #3
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    118
    Thanks
    16
    Thanked 1 Time in 1 Post

    Default

    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.

    I'll have to debug

    Can anyone recommend a javascript debugger for IE??

  5. #4
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    118
    Thanks
    16
    Thanked 1 Time in 1 Post

    Default

    Thought I should note I resolved the initial problem by declaring the variable like so... despite its declaration in the script body

    Code:
    	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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •