Closed Bug 243475 Opened 20 years ago Closed 20 years ago

JavaScript doesn't work if xhtml page is served with application/xhtml+xml mime type

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 197586

People

(Reporter: vr, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8

Manipulating DOM from JavaScript on a XHTML page served with
application/xhtml+xml MIME type, as required by XHTML specification, results in
Error: uncaught exception: [Exception... "Object cannot be created in this
context"  code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)" ...]
error and javascript code is not executed.

Reproducible: Always
Steps to Reproduce:
1. Create a simple XHTML file, such as:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DOM bug test</title>
</head>
<body>
<script type="text/javascript">//<![CDATA[
document.write("will Asa test NASA");
//]]></script>
</body>
</html>

2. Serve this file with an application/xhtml+xml MIME type


Actual Results:  
JavaScript is not executed.

Error: uncaught exception: [Exception... "Object cannot be created in this
context"  code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)" 
location: "http://localhost.gov/test.xhtml Line: 9"]


Expected Results:  
Page must be shown exactly as with text/html MIME type,
ie the text 

will Asa test NASA

should appear in the browser.
see Bug 197586, Bug 215904 and others.
Yep.  There's no document.write in XML documents.

*** This bug has been marked as a duplicate of 197586 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.