Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Storing statistics --> Part 2

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
41 active users
177 visitors today
725 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2010 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

The Footer script

First, the following code was added to the Footer() function in utils/Footer.asp.

Out ( '<script language="JavaScript" type="text/javascript">' );
   Out ( 'var sWidth = \'?width=\' + screen.width;' );
   Out ( 'var sRefer = \'&refer=\' + document.referrer;' );
   Out ( 'var sURL = \'&url=\' + document.URL;' );

   Out ( 'document.write(\'<img src="StatCounter.asp\' + sWidth + sRefer + sURL + \'" width=1 height=1 border=0 alt="">\' );' );
Out ( '</script>' );

// now for those brain dead browsers that don't support
// JavaScript, or who have it turned off
Out ( '<noscript><img src="StatCounter.asp" width=1 height=1 border=0 alt=""></noscript>' );

After the <script> statement, which marks the start of the client-side script, I store some information that the browser freely provides.

There is much more information than this, but it very quickly gets untidy dealing with IE/NS/Opera differences. This was all I needed anyway.

The "document.write" statement outputs the contents to the browser as if it was originally part of the HTML stream - it's just an <img> tag with my data passed in the URL. Note that instead of an gif or jpg being referenced, the URL points to an asp file!

Lastly, I use the <noscript> tag to output the <img> normally, without any extra information.

Part 3: The StatCounter.asp "image"...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!


See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!