Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript/Cgi communication - Logging Browser info

Options
  • 24-08-2001 5:14pm
    #1
    Registered Users Posts: 2,119 ✭✭✭


    Hey there,

    If I wanted to log info about browser's version/os/resolution how would I go about it.

    I know you can check some things with the HTTP_AGENT env variable, but I want to check things like resolution and any other things I can think of to get a decent idea of who's viewing the site.

    Is this usually done with javascript, and if so, how is it done. (:

    Thanks,

    - Kevin


Comments

  • Registered Users Posts: 12,309 ✭✭✭✭Bard


    thecounter.com might be of some help to you...


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Yeah, there's very little information you can get about the client side without using client-side scripting. It's pretty easy to do though, you just sniff them with JavaScript and pass them to a server-side script. You can do that in one of three ways - slot the variables into a form and have the user submit it (or submit it programmaitically); slot them into a QUERY_STRING and redirect; or slot them into cookies and retrieve them on the next page load.

    Without knowing what kind of server-side language you're using and what the application is, I couldn't give you any details though (I'm not going through all of 'em smile.gif).

    adam


  • Registered Users Posts: 2,119 ✭✭✭p


    I basically just want to run a little counter on my page.
    I want to write it myself though.

    Language would probably be Perl or PHP.

    I imagine the techniques are pretty similar.

    Someone else suggested to me simply having javascript use an image tag to pass info to a CGI and return a simple 1x1 pixel image. I think that looks like the best idea at present.

    - Kevin


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    You don't need anything done client-side (with JavaScript) as you can grab all the environment variables from the request variables sent to the server.

    In Perl you can get a list of the available request headers thus:
    #!/usr/local/bin/perl
    
    print "Content-type: text/htmlnn";
    foreach $env_var (keys %ENV) {
    print "<BR>$env_var is set to $ENV{$env_var}";
    }
    

    While in PHP you can get most information using the phpinfo() function (you can do a foreach too, just can't remember what the array is called).

    How you write this (as a false image or just an SSI) and how you intend to record your data (concurrency issues, etc.), I'll leave up to you.

    Hope this helps.

    "Just because I'm evil doesn't mean I'm not nice." - Charlie Fulton


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    <font face="Verdana, Arial" size="2">Originally posted by The Corinthian:
    You don't need anything done client-side (with JavaScript) as you can grab all the environment variables from the request variables sent to the server.</font>

    Not client-side environment variables though Corinthian, like screen width and height, and resolution.

    adam


  • Advertisement
  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    <font face="Verdana, Arial" size="2">Originally posted by dahamsta:
    Not client-side environment variables though Corinthian, like screen width and height, and resolution.</font>

    Upps, fair enough. Most things you won't need anything client-side, screen width and height, and resolution you regrettibly do (I wasn't reading the post carefully enough) - in which case use something based on this:
    if (document.all) {
        height = document.body.offsetHeight;
        width = document.body.offsetWidth;
        browser = "Internet Explorer";
    } else if (document.layers) {
        height = window.innerHeight;
        width = window.innerWidth;
        browser = "Netscape";
    }
    document.write("Browser: " + browser + "&lt;br&gt;");
    document.write("height: " + height + "&lt;br&gt;");
    document.write("width: " + width);
    

    And send it back to the server as a POST or GET.

    "Just because I'm evil doesn't mean I'm not nice." - Charlie Fulton


Advertisement