xhtml valid counter needed!

Discussion in 'HTML & Website Design' started by naturaldesigns, May 17, 2006.

  1. #1
    Hey all!

    I've tried many stat counters but all of them aren't xhtml valid which is pretty annoying...which one can you recommend?

    regards
     
    naturaldesigns, May 17, 2006 IP
  2. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If the counter originates within your own server, you could just make the changes to the script necessary to have it produce valid XHTML. A counter typically requires very little code to display. I have to think this wouldn't take more than a minute or two.
     
    the_pm, May 17, 2006 IP
  3. naturaldesigns

    naturaldesigns Member

    Messages:
    57
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    Hey!

    The codes are: (2 counters)

    
    
    <!-- Start of StatCounter Code -->
    <script type="text/javascript" language="javascript">
    var sc_project=1532004;
    var sc_invisible=1;
    var sc_partition=14;
    var sc_security="509cc2d0";
    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://c15.statcounter.com/counter.php?sc_project=1532004&amp;java=0&amp;security=509cc2d0&amp;invisible=1" alt="hit counter code" border="0"> </noscript>
    <!-- End of StatCounter Code -->
    
    
    <!-- Start CounterSpot Code -->
    <script language="javascript">
    var data, p;
    var agt=navigator.userAgent.toLowerCase();
    p='http';
    if((location.href.substr(0,6)=='https:')||(location.href.substr(0,6)=='HTTPS:')) {p='https';}
    data = '&r=' + escape(document.referrer) + '&n=' + escape(navigator.userAgent) + '&p=' + escape(navigator.userAgent) + '&g=' + escape(document.location.href);
    if(navigator.userAgent.substring(0,1)>'3') {data = data + '&sd=' + screen.colorDepth + '&sw=' + escape(screen.width+ 'x'+screen.height)};document.write('<a href="http://www.counterspot.com/stats.php?i=1184" target="_blank" >');
    document.write('<img border=0 hspace=0 '+'vspace=0 alt="free counters" src="http://www.counterspot.com/counter.php?i=1184' + data + '">');
    document.write('</a>');
    </script><noscript><a href="http://www.counterspot.com" target="_blank" >free counters</a></noscript>
    <!-- End CounterSpot Code -->
    
    
    Code (markup):
    regards
     
    naturaldesigns, May 21, 2006 IP
  4. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #4
    See if this works for you:
    <!-- Start CounterSpot Code -->
    <script language="javascript">
    var data, p;
    var agt=navigator.userAgent.toLowerCase();
    p='http';
    if((location.href.substr(0,6)=='https:')||(location.href.substr(0,6)=='HTTPS:')) {p='https';}
    data = '&r=' + escape(document.referrer) + '&n=' + escape(navigator.userAgent) + '&p=' + escape(navigator.userAgent) + '&g=' + escape(document.location.href);
    if(navigator.userAgent.substring(0,1)>'3') {data = data + '&sd=' + screen.colorDepth + '&sw=' + escape(screen.width+ 'x'+screen.height)};document.write('<a href="http://www.counterspot.com/stats.php?i=1184" onclick="window.open(http://www.counterspot.com/stats.php?i=1184);return false;" >');
    document.write('<img style="border:none" alt="free counters" src="http://www.counterspot.com/counter.php?i=1184' + data + '" />');
    document.write('</a>');
    </script>
    <!-- End CounterSpot Code -->
    Code (markup):
    I only altered the second portion. Keep the first portion in place.

    Depending on the level of XHTML validity you are seeking, you may need to place all of this information into external files and call it in that way, but see if this does what you need it to do, and if not, copy/paste the validation errors you're seeing :)
     
    the_pm, May 21, 2006 IP
  5. naturaldesigns

    naturaldesigns Member

    Messages:
    57
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    naturaldesigns, May 21, 2006 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    The validator found one 'real' error, the script tag should be <script type="javascript">.

    Otherwise, the validator does not ignore the script and tries to validate it as html. Try wrapping the script in html comments[1]:
    
    <script type="javascript">
    //<!--
    ...
    //-->
    </script>
    Code (markup):
    cheers,

    gary

    [1] check that a double hyphen (--) does not appear in the script, as that will end the html comment.
     
    kk5st, May 21, 2006 IP
  7. phd

    phd Active Member

    Messages:
    496
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Use www.statcounter.com They offer xhtml compaint code also. In setup of the code check the xhtml option...
    enjoy :)
     
    phd, May 21, 2006 IP
  8. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #8
    That was my fault. I should have been more attentive with this line:

    <script language="javascript">

    which should be

    <script type="text/javascript">

    If you move all of the information within this ste of script tags into an external file, your problems are solved. So, place this on your page:

    <script type="text/javascript" src="counter.js"></script>

    And take all of the actual scripting, stick it into a file, and call it counter.js.
     
    the_pm, May 22, 2006 IP
  9. naturaldesigns

    naturaldesigns Member

    Messages:
    57
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #9
    Hey thanks all!
    especially the_pm!

    That was very helpful...also for future projects...thank you! I've now moved everything to an external file and it works perfect!

    thanks!
     
    naturaldesigns, May 22, 2006 IP
  10. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You're welcome. Glad I could be of assistance :)
     
    the_pm, May 23, 2006 IP