473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

IE6 SP1 workaround?

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>

Jul 23 '05 #1
3 1196
Adam Warner wrote:
<snip>
<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;


How about this approach:
<head>
<script type="text/javascript">
function test(s){
for (var c=0; c<s.length;c++)
document.write(s.charCodeAt(c).toString(16)+" ");
}
</script>
</head>

&gt;<script type="text/javascript">test('ABC');</script>&lt;
Jul 23 '05 #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.
Jul 23 '05 #3
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
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: klappnase | last post by:
Hello everyone, there have already been a couple of threads about IDLE's sometimes annoying disability to use special characters (in my case I would like to use for example german umlauts like...
0
by: Jonas Smithson | last post by:
<div style="position: relative;> <!-- I'm the parent --> blah blah blah <div style="position: absolute; bottom: 0;> <!-- I'm the child --> blah blah blah </div> </div> The bottom of the...
7
by: Justin Shen | last post by:
the output of the following codes is "greater than zero", which is rather strange! the correct one should be "not greater than zero" int a = 0x79de61c0; //2044617152; a += 0x12345678; //a is...
1
by: slyi | last post by:
Hi All, Does anyone use vml to force the printing of background-colors in IE clients? Regards, slyi eg: <html xmlns:v="urn:schemas-microsoft-com:vml" >
0
by: William Johnston | last post by:
Hi, A support technician proposed a workaround to black images created for thumbnails. The code to create a thumbnail is below: //passes results to Response.OutputStream private void...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.