Closed Bug 197226 Opened 21 years ago Closed 21 years ago

parser or JS issue caused by 1 self closing script tag followed by an other script tag

Categories

(Core :: JavaScript Engine, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: lrutker, Assigned: rogerl)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2) Gecko/20021126
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2) Gecko/20021126

The html below validated against the w3 validator.
the self closing first script tag causes the second script to not work.
It is either a parsing issue or a javascript issue.
changing:
<script language="JavaScript" type="text/javascript" 
src="/path/path/someScript.js" />
to:
<script language="JavaScript" type="text/javascript"
src="/path/path/someScript.js"></script>

will get the page to work

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
	<title>International Wach</title>
	<link rel="stylesheet" href="/path/path/style.css" type="text/css" />
        <script language="JavaScript" type="text/javascript"
src="/path/path/someScript.js" />
        <script language="JavaScript" type="text/javascript">
            function alertMe(){
                alert("this is an alert");
            }
        </script>
	</head>
	<body>
		<form method="post" name="myForm" action="/someOtherPage.jsp">
			<input type="button" value="press" onclick="JavaScript:alertMe();" />
		</form>
	</body>
</html>

Reproducible: Always

Steps to Reproduce:
1. take html above and save it locally
2. load into browser and try to press button
3. when nothing happens change self closing first script tag
4. reload page and click button
5. watch alert show up as it should

Actual Results:  
changing self enclosing tag to ></script> fixed problem

Expected Results:  
proper parsing

xhtml that does not work above woks in IE 5.5 but NOT IE6 (regression bug?)
If it works in IE, you're serving it as text/html.  <script /> is NOT a closed
tag in text/html content.

And looks like IE6 in fact _fixed_ a bug.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Thanks.
Does the same apply to the css tag or only the script tag? Are there any other
cases that are like the script tag?
Where can I find a reference that shows that the script tag can't be self closing?
Marking Verified.

I don't know the answer to the questions above, but a good place
to try is the Mozilla DOM newsgroup or similar:

  news://news.mozilla.org/netscape.public.mozilla.dom

It's not JS Engine, since the engine has no concept of HTML tags.
Status: RESOLVED → VERIFIED
See appendix C of the XHTML specification.  It describes the rules an XHTML file
must follow to work as text/html.  One of them is that nonempty tags need an
explicit end tag.  This would include <script>, <style>, etc.
Would the proper way to use my frist script tag be:
<link rel="script" href="/path/path/someScript.js" type="text/javascript" />
as opposed to:
<script language="JavaScript" type="text/javascript"
src="/path/path/someScript.js"></script>
?

Thanks for all the help
Not if you expect it to work with any current browser.
You need to log in before you can comment on or make changes to this bug.