Closed Bug 145471 Opened 23 years ago Closed 23 years ago

JS Console: document.write is not a function

Categories

(Core :: JavaScript Engine, defect)

x86
Windows 98
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 111514

People

(Reporter: thomas.scheffler, Assigned: rogerl)

Details

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; de-AT; rv:1.0rc2) Gecko/20020510
BuildID:    2002051006

As suggest in chapter 4.8 of http://www.w3.org/TR/2000/REC-xhtml1-20000126/ I
put in my xhtml (strict) document between my script tags a cdata section. This
is why suddenly mozilla is not able to find the write() method of the document
object. If you remove the CDATA instruction the whole script runs without a
glitch. This only happens if the document is Content-Type: text/xml. As noted in
chapter 4.10 it should be send as text/html, but another error occure then. I'll
post in an other error report if bug is not yet in database.

Reproducible: Always
Steps to Reproduce:
1.simply run the testcase with content-type: text/xml


Actual Results:  JavaScript Console found an error:
document.write is not a function (line 22)

Expected Results:  function writeEmail() should insert a link in place

<?xml version="1.0" encoding="ISO-8859-15"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
 <head>
  <title>testcase</title>
  <meta http-equiv="Content-type" content="text/html; charset=iso-8859-15"/>
 <meta name="language" content="Deutsch"/>
 <meta name="robots" content="index,follow"/>
 <meta name="audience" content="Alle"/>
 <meta name="copyright" content="Thomas Scheffler"/>
 <meta name="author" content="Thomas Scheffler"/>
 <meta name="page-topic" content="mozilla Testcase"/>
 <meta name="description" content="Mozilla Testcase for document.write"/>
 <meta name="keywords" content="Thomas Scheffler, Jena, Scheffler,
Kuriosit&auml;ten, Videos, Video Clips, krass"/>
 <script type="text/javascript"><![CDATA[
  <!--
  function writeEmail(linkText){
    var domain="domain.de";
    var user="webmaster";
    if (!linkText) linkText=user+"@"+domain;
    document.write("<a href=\"mailto:"+user+"@"+domain+"\">"+linkText+"</a>");
  }
  //-->
  ]]></script>
 </head>
<body>
<p>
<script type="text/javascript">writeEmail("Thomas Scheffler");</script>
</p>
<p style="text-align:right;">
<a href="http://validator.w3.org/check/referer">
  <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!"
height="31" width="88" style="border-style:none;" />
</a>
</p>
</body>
</html>
When bug 27403 is fixed, this should be checked again for content-type text/html.
Depends on: 27403
This is almost certainly a dupe of 111514.  The problem with document.write has
been noted in 111514, via the 18th comment.  

Frankly I'm VERY surprised the script executed at all.  Mozilla typically
ignores XML comments (<!--...-->).

*** This bug has been marked as a duplicate of 111514 ***
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
No longer depends on: 27403
Resolution: --- → DUPLICATE
I oughta cc myself on any bug I mark DUPLICATE.
Verified Duplicate.

Alex: thanks!
Thomas: you have been cc'ed on the other bug so you may follow its progress - 

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.