Forum Moderators: open

Message Too Old, No Replies

Does statcounter code ever validate?

Or, better yet, how can I force it to?

         

Perfection

8:50 pm on Jun 20, 2006 (gmt 0)

10+ Year Member



I'm trying to put statcounter's code on my site, and it doesn't validate (html 4.01 strict). Oddly enough, it had an option to select when generating the code for it to be "w3c compliant."

I selected this option and it still doesn't validate.

This is the code:

<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
<!--
var sc_project=######;
var sc_invisible=1;
var sc_partition=15;
var sc_security="######";
var sc_remove_link=1;
//-->
</script>

<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><img src="http://c16.statcounter.com/counter.php?sc_project=######&java=0&security=######&invisible=1" alt="counter" border="0"> </noscript>
<!-- End of StatCounter Code -->

After replacing the &'s with &amp;, I still get 4 errors.

there is no attribute "LANGUAGE"
there is no attribute "BORDER"
document type does not allow element "IMG" here;
end tag for "NOSCRIPT" which is not finished

Any ideas for how I can get this code to validate and, ya know, still actually do what it's meant to do in the first place?

Thanks in advance for any help.

encyclo

12:14 am on Jun 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Once the
&
is replaced with
&amp;
in the URL, the code validates to HTML 4.01 Transitional. In fact it's not too difficult to make it validate to HTML 4.01 Strict. The differences are that you must remove the
language="javascript"
attributes (which are not needed anyway), place the image within a block-level element within the
noscript
and swap out the
border 
attribute for a bit of CSS:

<!-- Start of StatCounter Code -->
<script type="text/javascript">
<!--
var sc_project=######;
var sc_invisible=1;
var sc_partition=15;
var sc_security="######";
var sc_remove_link=1;
//-->
</script>

<script type="text/javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript>[b]<div>[/b]<img src="http://c16.statcounter.com/counter.php?sc_project=######[b]&amp;[/b]java=0[b]&amp;[/b]security=######[b]&amp;[/b]invisible=1" alt="counter" [b]style="border:0;"[/b]>[b]</div>[/b] </noscript>
<!-- End of StatCounter Code -->

Tha above validates as Strict with no functional difference.

Perfection

1:05 am on Jun 21, 2006 (gmt 0)

10+ Year Member



Huge thank you my friend.