473,382 Members | 1,165 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,382 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 1199
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...
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...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.