Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    217
    Thanks
    52
    Thanked 1 Time in 1 Post

    This is info, not a question about strings

    For anyone who doesn't already realize this, I have been having trouble with
    Internet Eplorer window freezes and have traced it to the way my code was
    handling strings.
    where I used
    Code:
    // even though this will work in every other browser tested:
    var str = 'some text';
    for(var i = 0; i < str.length; i++)
       {
         if(str[i] == 's') /////<<<<<< this will freeze Internet Explorer window
          { 
            // do something 
          }
       }
    The following was the fix
    Code:
    var str = 'some text';
    for(var i = 0; i < str.length; i++)
       {
         if(str.charAt(i) == 's') /////<<<<<< This will work
          { 
            // do something 
          }
       }

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    29,435
    Thanks
    85
    Thanked 4,912 Times in 4,873 Posts
    It doesn't freeze in MSIE 9. On the other hand it doesn't work.

    If you try doing alert(str[7]); (for example), you get just "undefined".
    Be yourself. No one else is as qualified.

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    217
    Thanks
    52
    Thanked 1 Time in 1 Post

    I was referring to IE 7

    All the testing I was doing, and bug chasing was in Internet Explorer 7. This would be a issue for backward compatibility most likely. Your info is useful as well.

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,115
    Thanks
    56
    Thanked 579 Times in 575 Posts
    thanks for the info. IE8 returns undefined, too, fwiw

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,258
    Thanks
    43
    Thanked 518 Times in 512 Posts

    Question

    Post #1 was interesting,
    but for all the observations and testing in the MSIE browsers
    what is the reason for the 'freeze' or 'undefined' messages?

    Appears to be valid and innoculus code.
    What is the underlying problem that is going on to cause this particular action?
    Why would MSIE work like this?

  • #6
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,115
    Thanks
    56
    Thanked 579 Times in 575 Posts
    MDN says that str[7] is part of ECMAScript 5 but not ECMAScript 3, which I guess would explain the IE<9 thing

    I'm surprised because IE8 can return str.length correctly and I was under the impression that anything with a length could be accessed using array notation.

    But I guess not.


  •  

    Posting Permissions

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