Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > IE6 SP1 workaround?

Reply
Thread Tools

IE6 SP1 workaround?

 
 
Adam Warner
Guest
Posts: n/a
 
      11-09-2004
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>

 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      11-09-2004
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.


 
Reply With Quote
 
 
 
 
Adam Warner
Guest
Posts: n/a
 
      11-09-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile on 3.5 sp1 and deploy on non 3.5 sp1 server? Vijay ASP .Net 1 11-01-2008 12:45 PM
Re: Where to get stand alone Dot Net Framework version 1.1, version2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? MowGreen [MVP] ASP .Net 5 02-09-2008 01:55 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? PA Bear [MS MVP] ASP .Net 0 02-05-2008 03:28 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? V Green ASP .Net 0 02-05-2008 02:45 AM
IE6 SP1 rendering vs IE6 SP2 rendering Peter Mount HTML 4 01-31-2006 08:01 AM



Advertisments