PDA

View Full Version : Resolved Validation error because of Javascript ?



Cheng
04-05-2009, 07:48 AM
Hi.

I get a validation error when I add this script into the footer of the page:


<div id="footer">
<div id="width"> <span class="floatLeft">
<!-- Begin Shinystat Free code -->
<script type="text/javascript" language="JavaScript" src="http://codice.shinystat.com/cgi-bin/getcod.cgi?USER=username"></script>
<noscript>
<a href="http://www.shinystat.com" target="_top">
<img src="http://www.shinystat.com/cgi-bin/shinystat.cgi?USER=username" alt="website counter" border="0"></a>
</noscript>
<!-- End Shinystat Free code -->
</span> <span class="floatRight">Copyright 2009 - All rights reserved.</span> </div>
</div>

It's because of the code that is between the <noscript> tags.

The page is valid XHTML if I take out:


<noscript>
<a href="http://www.shinystat.com" target="_top">
<img src="http://www.shinystat.com/cgi-bin/shinystat.cgi?USER=username" alt="website counter" border="0"></a>
</noscript>

The image of the counter is still loading but I'm not sure if it got some effect on the counter even though it seems to work.

Could I load this script with an external javascript file?

And if yes, what is the right way to do it?

Please give me some advise here.

Any feedback is very much appreciated,

Twey
04-05-2009, 01:30 PM
You should be using HTML 4.01 Strict on the Web right now, since IE doesn't have support for XHTML.

The target attribute is not valid HTML (or XHTML). It was deprecated in HTML4, and removed from the Strict DTD.

Cheng
04-06-2009, 07:02 AM
Hi Twey.

Thanks for your reply.

I changed the doctype to HTML strict but there is still the validation error for <noscript>

Even without the target attribute it still comes up with the <noscript> error.

Do got any idea what can be done about it?

Snookerman
04-06-2009, 07:16 AM
Remove the highlighted:

</noscript>
<!-- End Shinystat Free code -->
</span> <span

Good luck!

Cheng
04-06-2009, 09:51 AM
Remove the highlighted:

</noscript>
<!-- End Shinystat Free code -->
</span> <span

Good luck![/CODE]

.......sorry, but it didn't work.

It put everything out of perspective.

I applied doctype HTML Transitional and everything is fine except for this one validation error:


Line 98, Column 14: document type does not allow element "NOSCRIPT" here; missing one of "APPLET", "OBJECT", "MAP", "IFRAME", "BUTTON" start-tag

<noscript>

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

I wonder if it causes any harm to the counter if I leave the whole noscript part out.

Without it the counter is showing up same as with the noscript applied and it seems to count as well but as I said I'm not sure if it is ok to take that part out or not.......

Snookerman
04-06-2009, 10:38 AM
I think what you have done is wrapped everything in a <span> tag which is an inline element. Please post the entire code or a link to the site and I'll tell you what to remove.

Cheng
04-06-2009, 11:43 AM
I think what you have done is wrapped everything in a <span> tag which is an inline element. Please post the entire code or a link to the site and I'll tell you what to remove.

.......Hi Snookerman.

Attached you'll find a txt file which contains the HTML code.

I really do appreciate your effort to help.

Thanks a lot.......

Snookerman
04-06-2009, 12:07 PM
Just as I thought, you have everything wrapped inside a <span> tag:

<div id="footer">
<div id="width"> <span class="floatLeft">
<!-- Begin Shinystat Free code -->
<script type="text/javascript" language="JavaScript" src="http://codice.shinystat.com/cgi-bin/getcod.cgi?USER=benjapakee"></script>
<noscript>
<a href="http://www.shinystat.com" target="_top"> <img src="http://www.shinystat.com/cgi-bin/shinystat.cgi?USER=benjapakee" alt="Free blog counters" border="0"></a>
</noscript>
<!-- End Shinystat Free code -->
</span> <span class="floatRight">Copyright 2009 by Tommy's Enterprises - All rights reserved.</span> </div>
</div>
Change that to a div container:

<div id="footer">
<div id="width"> <div class="floatLeft">
<!-- Begin Shinystat Free code -->
<script type="text/javascript" language="JavaScript" src="http://codice.shinystat.com/cgi-bin/getcod.cgi?USER=benjapakee"></script>
<noscript>
<a href="http://www.shinystat.com" target="_top"> <img src="http://www.shinystat.com/cgi-bin/shinystat.cgi?USER=benjapakee" alt="Free blog counters" border="0"></a>
</noscript>
<!-- End Shinystat Free code -->
</div> <span class="floatRight">Copyright 2009 by Tommy's Enterprises - All rights reserved.</span> </div>
</div>
Note that you might have to change the CSS code for this element if it targets the span tag specifically.

Good luck!

Cheng
04-06-2009, 01:30 PM
......I tried that but it didn't work unless I misunderstood you.

I changed the footer to:


<div id="footer">
<div class="floatLeft">
<!-- Begin Shinystat Free code -->
<script type="text/javascript" language="JavaScript" src="http://codice.shinystat.com/cgi-bin/getcod.cgi?USER=benjapakee"></script>
<noscript>
<a href="http://www.shinystat.com" target="_top"> <img src="http://www.shinystat.com/cgi-bin/shinystat.cgi?USER=benjapakee" alt="Free blog counters" border="0"></a>
</noscript>
<!-- End Shinystat Free code -->
</div> <span class="floatRight">Copyright 2009 by Tommy's Enterprises - All rights reserved.</span> </div>
</div>
</body>
</html>

This destroys the whole footer which is fixed to the bottom of the page by the way.......

Snookerman
04-06-2009, 03:40 PM
Now you removed a div with the id of width. Just copy and paste what I posted.

Cheng
04-07-2009, 11:18 AM
.......thanks a lot Snookerman!!!

This document was successfully checked as HTML 4.01 Transitional!

Sorry that I didn't get in the 1st place but now I can see it that you just changed:

<span class="floatLeft"></span> to <div class="floatLeft"></div>

There was no need to change the CSS as well.

I really do appreciate your help.

Thanks again very much.......

Snookerman
04-07-2009, 11:43 AM
You're welcome, glad to help!
You can go to your first post in this thread, click http://www.dynamicdrive.com/forums/images/buttons/edit.gif then click Go Advanced and add the Resolved prefix to the thread title.
This will let other users know the problem has been solved.

Good luck with your site!