document.write, HTML entities and IE

G

Geoff Wilkins

I must confess I only come here when I have a problem - so my apologies
if this has been raised before:

Using my IE v.6 browser, document.write doesn't convert HTML entities
(e.g. ', &) to the appropriate character (though NS 6.2 works
fine).

Obviously I can get round this for particular entities by writing some
code to do the conversion before using document.write - but I need a
more general solution that will catch any of the HTML entities.

A trawl with Google has found a number of people raising the question,
but no answers. Any suggestions?
 
G

Geoff Wilkins

Many thanks for this - I should have experimented a little more before
asking.

Are there any other HTML entities that IE6 doesn't convert?
 
D

DU

HikksNotAtHome said:
IE6 doesn't convert ' to an apostrophe even when its hard-coded.

'test' in a test page, in NS7 displays 'test' while in IE6, it
displays as written. So its not the document.write thats failing, its the
browser itself in its HTML side. Note: It does convert © to the copyright
symbol, whether hard coded or document.write generated.

Character entity references in HTML 4
http://www.w3.org/TR/html401/sgml/entities.html

"The named character reference ' (the apostrophe, U+0027) was
introduced in XML 1.0 but does not appear in HTML. Authors should
therefore use ' instead of ' to work as expected in HTML 4 user
agents."
C.16. The Named Character Reference '
http://www.w3.org/TR/2002/REC-xhtml1-20020801/#C_16

I tested
document.write("& '");
in MSIE 6 SP2 for windows in an HTML 4.01 strict DTD and it worked
without a problem.

I then tested
document.write("& '");
in MSIE 6 SP2 for windows in an XHTML 1.0 strict DTD and ' was not
converted into an '. \u0027 worked though.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunclear/Netscape7/Netscape7Section.html
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top