IE6 SP1 workaround?

Discussion in 'Javascript' started by Adam Warner, Nov 9, 2004.

  1. Adam Warner

    Adam Warner Guest

    Hi all,

    Can someone please explain why the HTML below prints >< in Microsoft
    Internet Explorer 6 SP1 (at least on the machine I tested) instead of
    >41 42 43 <? Active scripting is enabled.


    Thanks,
    Adam

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head><title>Titles are Mandatory</title></head>
    <body>
    <script type="text/javascript">
    function test() {
    s="ABC";
    for (c in s) {
    document.write(s.charCodeAt(c).toString(16)+" "); }}
    </script>
    &gt;<script type="text/javascript">test();</script>&lt;
    </body>
    </html>
     
    Adam Warner, Nov 9, 2004
    #1
    1. Advertising

  2. Adam Warner wrote:
    > Can someone please explain why the HTML below prints
    > >< in Microsoft Internet Explorer 6 SP1 (at least

    > on the machine I tested) instead of >41 42 43 <?
    > Active scripting is enabled.
    >

    <snip>
    > <script type="text/javascript">
    > function test() {
    > s="ABC";
    > for (c in s) {

    <snip>

    Here - s - is a string. The - for (prop in obj) - statement will
    type-convert - s - into an object. That object is a String object. By
    specification String objects do not have properties that index the
    characters in the string (though Mozilla's strings are implemented that
    way, but there is still no reason to expect such properties to be
    enumerable even if implemented).

    try:-

    var s = new String("ABC");
    for( var c = 0; c < s.length;c++){
    document.write(s.charCodeAt(c).toString(16)+" ");
    }

    And do remember to use the - var - keyword within functions to make
    variables that do not need to be global into local variables.

    Richard.
     
    Richard Cornford, Nov 9, 2004
    #2
    1. Advertising

  3. Adam Warner

    Adam Warner Guest

    Hi Richard Cornford,

    > Here - s - is a string. The - for (prop in obj) - statement will
    > type-convert - s - into an object. That object is a String object. By
    > specification String objects do not have properties that index the
    > characters in the string (though Mozilla's strings are implemented that
    > way, but there is still no reason to expect such properties to be
    > enumerable even if implemented).


    Brilliant. Thanks Richard and mscir. I got into this mess because I tried
    iterating over the characters in the string (indeed using Mozilla) and was
    surprised to find the iterating variable was bound to the index of the
    character instead of the character itself. So you can see what I did next :)

    > And do remember to use the - var - keyword within functions to make
    > variables that do not need to be global into local variables.


    A very helpful tip. I'm well versed in Common Lisp so I merely have to
    learn all the unfortunate deviations :)

    Regards,
    Adam
     
    Adam Warner, Nov 9, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jens Lenge

    DIV height - IE6 workaround?

    Jens Lenge, Mar 5, 2005, in forum: HTML
    Replies:
    16
    Views:
    29,939
    kchayka
    Mar 8, 2005
  2. Peter Mount
    Replies:
    4
    Views:
    960
    Peter Mount
    Jan 31, 2006
  3. Just Me

    IE6 Bug Workaround ?????

    Just Me, Mar 28, 2008, in forum: ASP .Net
    Replies:
    7
    Views:
    2,672
    Just Me
    Mar 29, 2008
  4. Vijay
    Replies:
    1
    Views:
    315
    Joern Schou-Rode
    Nov 1, 2008
  5. Judy
    Replies:
    0
    Views:
    1,051
Loading...

Share This Page