#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Canada
    Posts
    368
    Rep Power
    12

    javascript web traffic script not working NS4.x


    I finally have this program working to track my web stats using php, mysql and javascript: http://www.andrewkimball.com/ (statz)

    It works fine for IE Explorer but doesn't work at all through NS4.x. That is, if I visit the site with NS4.7 the visit is not recorded in my mysql database. I strongly suspect there is something wrong in my placement of the script that records the visit to a page...below (not php...):
    PHP Code:
            <script language="JavaScript">            
                var 
    image "pixel.gif";            
                var 
    web "mywebsite.com";            
                var 
    from escape(document.referrer);    
                var 
    page "name_of_page.html";
                var 
    query location.search;
                var 
    colorDepth window.screen.colorDepth;            
                var 
    res window.screen.width "," window.screen.height;            
                var 
    maxres window.screen.availWidth "," window.screen.availHeight;            
                if (
    navigator.javaEnabled() == 1){ var javaa "Enabled";} else {var javaa "Disabled";}            

                
    document.write("<img src='path_to_hit.php?referer=" from "&request=" page "&website=" web "&query=" query "&cDepth=" colorDepth "&resol=" res "&maxresol=" maxres "&java=" javaa "&img=" image "' align='middle' style='display:none'>");     
            
    </script> 
    I know next to nothing about javascript, but in order to get it to work on most of my pages, I had to insert this script in the html header - i.e., between <head> and </head>. This method works fine for IE6 but not NS4.7. Further, if I put the script elsewhere some of my pages will not work (forms in particular) but NS4.7 visits still don't register with this method.

    I know I should be talking with the program developer, but he is unresponsive and his forum is not working - there is no support there.

    Any thoughts? Your direction is much appreciated.
    mr_fitz
    __________
    Don't worry, I haven't given up my day job.
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    First of all, this script outputs HTML, so it's designed to go in the <body>...
    IE may not mind, but it rarely does. Secondly, inline CSS (<img....style="...")
    is murder in NS4. Try putting this in the <head>er:

    <style type="text/css">

    .out {
    display: none;
    }

    </style>

    ...and

    document.write("<img class="out" src='path_to_hit.php?.........style='display:none'>");

    ...removing the red bits.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Canada
    Posts
    368
    Rep Power
    12

    helped...


    Thank-you, that really helped.

    I discovered that NS4.x still doesn't like your replacement <style> script though adios, for placement in the <head>. I just removed the style from the img call and left it at that. I am not sure why it is there in the firstplace, as nothing else seems to have changed with its departure from the script and page altogether.

    I also discovered another peculiarity of this script. In on page I placed it at the end, before </body> and it did not work. I place it further up the page, close to the </head> and it works fine. This is very odd. I have it solved, but just don't know why that would happen.

    NS + javascript is tricky business I guess.

    thanks again.
    mr_fitz
    __________
    Don't worry, I haven't given up my day job.

IMN logo majestic logo threadwatch logo seochat tools logo