Closed
Bug 260610
Opened 22 years ago
Closed 22 years ago
document.write is incorrectly rendered when page has <!DOCTYPE specified
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: geoffphillips, Unassigned)
References
()
Details
Attachments
(1 file)
|
530 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10
Javascript following a document.write("</script>"); call is rendered as HTML and
the expected text is not rendered:
Example page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
</head>
<body>
<script type="text/javascript" language="javaScript">
<!--
document.write("<script type=\"text/javascript\"
language=\"javaScript\">\n");
document.write("document.write(\"You should be able to see
this<br>\");\n");
document.write("</script>");
// You shouldn't be able to see this!
//-->
</script>
</body>
</html>
This page should display as:
You should be able to see this
Instead it displays:
"); // You shouldn't be able to see this! //-->
i.e. It didn't display the expected text, instead it displays the text following
the </script> tag within the expected text.
With no <!DOCTYPE specified the page renders correctly
This is possibly a duplicate of bug 97886
Reproducible: Always
Steps to Reproduce:
Look at a page containing the HTML above.
Try deleting the <!DOCTYPE tag at the top, the correct text should be displayed
Actual Results:
The script displayed:
"); // You shouldn't be able to see this! //-->
Expected Results:
The script should have displayed:
You should be able to see this
| Reporter | ||
Comment 1•22 years ago
|
||
Comment 2•22 years ago
|
||
I would suggest Resolution: Invalid, based on the FAQ of validator:
http://www.htmlhelp.com/tools/validator/problems.html#script
http://validator.w3.org/
on the testcase: had to override encoding:
http://validator.w3.org/check?uri=http%3A%2F%2Fbugzilla.mozilla.org%2Fattachment.cgi%3Fid%3D159494%26action%3Dview&charset=iso-8859-1+%28Western+Europe%29&doctype=%28detect+automatically%29
Line 15, column 11: end tag for element "SCRIPT" which is not open
</script>
The Validator found an end tag for the above element, but that element is not
currently open. This is often caused by a leftover end tag from an element that
was removed during editing, or by an implicitly closed element (if you have an
error related to an element being used where it is not allowed, this is almost
certainly the case). In the latter case this error will disappear as soon as you
fix the original problem.
If this error occured in a script section of your document, you should probably
read this FAQ entry.
http://www.htmlhelp.com/tools/validator/problems.html#script
And now the original website:
As the ENCODING was missing, validator gave it a try assuming UTF-8
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.virginmobile.com%2Fmobile%2F
Sorry, I am unable to validate this document because on line 123 it contained
one or more bytes that I cannot interpret as utf-8 (in other words, the bytes
found are not valid values in the specified Character Encoding). Please check
both the content of the file and the character encoding indication.
Overriding the detected DOCTYPE XHTML 1.0 transitional
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.virginmobile.com%2Fmobile%2F&charset=iso-8859-1+%28Western+Europe%29
with HTML 4.01 transitional
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.virginmobile.com%2Fmobile%2F&charset=iso-8859-1+%28Western+Europe%29&doctype=HTML+4.01+Transitional
reduced number of errors from 154 to 65
Comment 3•22 years ago
|
||
invalid, the <script> is closed at the first </script>.
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
Comment 4•22 years ago
|
||
Verified. Note that the doctype you are using puts Mozilla in standards mode.
In quirks mode we do broken parsing that has your expected results...
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•