Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Gaborone, Botswana
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script in script, is it possible?

    Hi,

    I have a problem. I got a hit counter from Statsmachine.com. It requires that i add this code:

    <script src="http://www.statsmachine.com/cgi-bin/counter/382/38252.cgi"></script>

    in the head of every page i want logged. Now, i don't want to add a count when i access the page, so i used this method:

    http://www.irt.org/script/1014.htm.

    This means that i would have to put the script counter code in a <script>...</script>. It seems that this is not possible. Is there another solution that i could use?

    I was thinking that maybe there is a way to put the src= in the script, instead of in the tag. Then it should work....


    d52477001

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    you can do this:
    <script>document.write('<script src="http://www.statsmachine.com/cgi-bin/counter/382/38252.cgi"></sc' + 'ript>')</script>

    that should do what you want. you need to be sure to separate that </script> tag the way i did (in bold), because otherwise, the javascript interpreter, will get confused, and cause an error
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Actually, it's not "</script>" that causes the problem, it's "</". This is easily corrected by escaping it using "<\/".

    The reason for this is that the script is a CDATA containing element, and since no tags inside it are parsed, the first end tag must be the end of the CDATA block. (Basic SGML). This is not the case for XML, where no element have inherent CDATA blocks. There you must use explicit CDATA blocks (<![CDATA[ to ]]>) to be able to use the characters "<" and "&amp;" in scripts at all. Also, if you in XML use comments, you can not allow them to contain "--" since that ends the comment data. XML parsers are allowed to just ignore all comments, however, and then the script parser won't have anything to parse at all.
    Last edited by liorean; 06-03-2003 at 01:05 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Gaborone, Botswana
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yep, that did the trick... thanks!

    I now only have the problem that if the cookie is found, it does not display the counter. It needs to have the

    <script src="http://www.statsmachine.com/cgi-bin/counter/382/38252.cgi"></script>

    ...executed to show the counter. Yet, if the script is executed, then it is added to the counter...

    d52477001

  • #5
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    i think that's something that you'll need to take up with the counter's author
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #6
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Gaborone, Botswana
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yeah i did that and i got the location of the js file where the count is stored. So now my problem is solved. thanks.

    d52477001


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •