question about web counter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srinpraveen
    New Member
    • Nov 2006
    • 19

    question about web counter

    I badly want to know if there is a way in javascript to just a create a variable and increment it each time a particular visits the page. In other words, I want to use this as a counter for counting the visitors. Is this possible without the knowledge of scripting languages like php, perl etc..?

    If so please give me very simple instructions as to how to perform this task as I am a thorough novice to javascript. I am just in the process of learning javascript now.

    Also I would like to mention that when I googled for this requirement of mine there was a website which stated something about creating a deadframe to increment.

    Here is what it said.
    """""""
    Well, if you just want to display the counter and the counter simply
    increases an integer in a text-file containing nothing else than that
    integer, you could simply load it into a dead frame (width or height
    set to 0, name set to counterFrame). Read the frames content with
    parent.frames['counterFrame'].document.inner HTML and write it using
    document.write( counter).

    <script language="JavaS cript">
    <!--
    var counter = parent.frames['counterFrame'].document.inner HTML;
    document.write( '<p>' + counter + '</p>');
    //-->
    </script>

    """""""""""

    Please elaborate on this frames stuff. I do not know much about javascript-frame connection. Thank You for your assistance.
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    To keep a total count of how many people has been on the page you would want to use some sort of database or even textfile to write to because variables will not stay everytime someone goes to the page. This can be done with ASP, PHP, JS, PERL pretty much anything that can write a text file or database.

    Comment

    • mybay
      New Member
      • Dec 2006
      • 7

      #3
      Hi srinpraveen, I'm afraid I wont satisfy your question, but I may point you in the right direction.

      The problem with client-side scripts/languages like JavaScript is that you can perform things using it on the web page only while the user is on that page and you cant save anything once the user leaves the page or closes the browser. So if a user keeps refreshing one of the frames on your website you can count the number of times he did it in another frame, but once he leaves your site all that information is lost. There may be a way to store this information using cookies or writing to a text file (not sure), but I dont think this is a way to go. The best thing to do is to use server-side scripting/languages like PHP or ASP. If you have access on your host to use either of those it will be exceedingly simple to do what your trying to do, find ready made examples on the web and get help with them. But to use a client-side technology to do server-side tasks is not only improper, but also practically impossible (even if there is a strange workaround).

      Comment

      • srinpraveen
        New Member
        • Nov 2006
        • 19

        #4
        hi all thanks a lot...iam a lot clearer about this now thanks to all of you guys' help

        Comment

        • iam_clint
          Recognized Expert Top Contributor
          • Jul 2006
          • 1207

          #5
          mybay
          its called ajax, or u could store the information in a cgi script..

          Comment

          Working...