Closed Bug 329384 Opened 20 years ago Closed 20 years ago

Incorrect handling of <script/> in XHTML1.0 Strict

Categories

(Firefox :: General, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 203398

People

(Reporter: dloose, Unassigned)

Details

User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 I'm in a bit of a rush, so I haven't done too much research into this issue, so I'm going to be as specific as possible. I'm in the process of coding a web page for a friend and the code below doesn't behave as I would expect. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Portable Living on Uncommon Ground (P.L.U.G)</title> <link rel="stylesheet" type="text/css" href="styles/default.css"/> <script type="text/javascript" src="scripts/menu.js"/> <script type="text/javascript"> //<!-- var menus = new Array(); function createMenus() { menus[0] = new Menu(document.getElementById("menu1"), document.getElementById("menu1Items")); menus[1] = new Menu(document.getElementById("menu2"), document.getElementById("menu2Items")); menus[2] = new Menu(document.getElementById("menu3"), document.getElementById("menu3Items")); menus[3] = new Menu(document.getElementById("menu4"), document.getElementById("menu4Items")); } //--> </script> </head> <body onload="createMenus();"> ... </body> </html> The JavaScript console gives me this error: Error: createMenus is not defined Source File: file:///Users/dave/Desktop/PLUG/index.html Line: 1 Removing the first script tag gets rid of the error (but introduces a new one because the Menu object is no longer defined). Turns out the problem is that I use the shortened tag ending for the first script tag (i.e., <script/>). My work-around looks like this: <script type="text/javascript" src="scripts/menu.js"> //<!-- Don't use the shortened (i.e., <script .../>) form of the tag or FireFox won't correctly --> //<!-- parse the next script block. --> </script> My code is 100% valid according to several validators and I don't understand why Firefox would balk at something so basic as a tag ending. The only other browser I'm testing with at the moment is Safari and it handles the page perfectly. Reproducible: Always
You're serving it as text/html, not application/xhtml+xml, right? Of course you are, or the SGML comments in your inline script would mean that whole block would be removed. XHTML served as text/html *is* HTML, not XML, and you don't get XML rules. If you can't serve it with the right mime-type, you have to stick to Appendix C "HTML that looks quite a bit like real XHTML" rules, including not using self-closing elements except for things like <br> that self-close in HTML. *** This bug has been marked as a duplicate of 203398 ***
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.