Forum Moderators: open

Message Too Old, No Replies

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

How to fix errors

         

gph

6:28 am on Jul 6, 2002 (gmt 0)

10+ Year Member



I get 3 warnings when using this tag. Or rather, I had countless warnings and now have 3. I don't know what I need to do to correct these. Your help is appreciated.

The first is a meta tag inside <noscript> which redirects the user to ask them to turn JavaScript on if they can. If they can't, I direct them to non-JavaScript pages.

Here is the tag:

<noscript><meta http-equiv="refresh" content="0; url=no_script/bridge.htm"></noscript>

And this is the warning:

Error: element "META" not allowed here; check which elements this element may be contained within

The next is the closing </head> tag and this is the warning:

Error: end tag for element "HEAD" which is not open; try removing the end tag or check for improper nesting of elements

The last is the <body> tag. And the warning:

Error: element "BODY" not allowed here; check which elements this element may be contained within

This is the top portion of the page. There are no other head tags in the page and one closing body tag:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test</title>
<noscript><meta http-equiv="refresh" content="0; url=no_script/bridge.htm"></noscript>
<script type="text/javascript" language="javascript" src="docs/Scripts.js"></script>
</head>
<body>

Thanks for your help.

dcheney

6:49 am on Jul 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you get the same errors if you move the <noscript> to after the <script> statement?

gph

7:19 am on Jul 6, 2002 (gmt 0)

10+ Year Member



I hadn't tried that but yes the errors are the same.

mbauser2

7:56 am on Jul 6, 2002 (gmt 0)

10+ Year Member



Sounds like you're using an SGML [w3.org] parser, but you still need to learn about SGML [w3.org].

The problem is that NOSCRIPT isn't allowed in HEAD because it's a block element [w3.org] like P and DIV. (SCRIPT is a special element that's treated differently.) Three lines in the DTD explain this:

%head.misc [w3.org] includes SCRIPT, STYLE, META, LINK, and OBJECT.

%head.content [w3.org] includes TITLE and BASE.

The element defintion for HEAD [w3.org] limits its content to %head.misc and &head.content. Any other elements are illegal in HEAD.

Explaining why you got the three errors you did:

As far as SGML parsers are concerned, you closed the HEAD as soon as you used the forbidden NOSCRIPT. HEAD and BODY tags are optional in the DTD you used, so the parser has to assume you've started the BODY when it sees an element that only occurs in the BODY. With me so far?

So your first error is telling you that you've got a META in the NOSCRIPT, which means you've META in the BODY. That is Not Allowed. You're lucky: In the Good Old Days, some validators might have given you two error messages there.

The second error is telling you that you've got an illegal </HEAD> tag, because you've technically stuck it in the middle of the implied BODY element.

Likewise, the third error is telling you that the explicit BODY element is illegal, because your document already has an implied BODY. (A valid HTML document can only have one BODY element.)

SGML -- It's black magic, but it's the black magic the Web is built on.

martinibuster

8:00 am on Jul 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Apart from mbauser2's wisdom,
Have you tried using "CSE HTML Validator" yet?

One of the things I like about it is that the software not only warns you that your code is funky, it offers suggestions for de-funkifying it.

It's the Dr. Scholls of HTML.

There's a free download at Bradleysoft.com (I think that's how you spell it). They're the same folks who made TopStyle.

gph

8:21 am on Jul 6, 2002 (gmt 0)

10+ Year Member



Thank you mbauser2, it makes sense to me now.

Is there a better/correct way of redirecting the JavaScript disabled? Should I just put a link to the <noscript> pages within the tag and in the body?

martinibuster, I haven't tried a CSE HTML Validator yet but will. There is no such thing as smelling to fresh :)

rewboss

2:32 pm on Jul 6, 2002 (gmt 0)

10+ Year Member



You could try redirecting the JavaScript enabled; it would look like this:

<script type="text/javascript">
self.location.replace('js_version.html');
</script>

Using replace() means that the new page will replace the current page in the browser's History list -- if you used self.location='js_version.html' you would break the Back button for all JavaScript enabled browsers.

gph

2:48 pm on Jul 7, 2002 (gmt 0)

10+ Year Member



Thanks rewboss, I'm thinking that because most of my visitors will be JavaScript enabled I'd rather subject the disabled to a redirect and let the majority of visitors just see the site.

I've never liked the fact that I was killing the back button on disabled browsers. Is there a cleaner method of directing disabled browsers to the right pages?

Your wisdom is appreciated.

rewboss

10:05 am on Jul 8, 2002 (gmt 0)

10+ Year Member



In the past, you could have got away with this -- more or less:

<script>
<!-- --> <meta http-equiv="refresh" content="0; url=no-js-page.html" />
</script>

I don't recommend using this method, though; it really is a nasty hack and liable to break in the future. And I'd be amazed if it validated.

gph

12:19 am on Jul 9, 2002 (gmt 0)

10+ Year Member



Nasty but ingenious rewboss lol. Unfortunately I can’t get Opera 6 to follow it the way it does with <noscript>.

I guess my best alternative is to do <noscript>link</noscript> in the body of the page.

Thanks all for your help.

ann

10:22 am on Jul 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gph,

From the example you gave I saw no closing html tag???????

Ann

g1smd

8:54 pm on Jul 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



He was only quoting the first few lines of the file, not including any of the stuff beyond the opening <body> tag.

A normal document would have continued with all the body content, followed by </body> and finally </html>. That was implied but not stated.

gph

3:58 am on Jul 12, 2002 (gmt 0)

10+ Year Member



Hi Ann and g1smd.

As g1smd stated there is one </html> tag. I removed <noscript> from the head as per mbauser2s suggestions and now get "No errors found!"

Thanks agian all.