C
Carter Smith
http://www.icarusindie.com/wiki/index.php/Server-Side_Javascript_Check
Sample source included
This method requires that your pages are PHP enabled and you have mySQL.
Although I suppose you could also use PHP sessions (not cookies as they're
client editable). You could actually use any server side scripting language
such as Perl or ASP and any database like MS SQL Server. I prefer PHP and
MySQL.
The short version is you have a default image displayed and then use
javascript to replace the default image with a script reference. The
browser will then load that script which counts the javascript hit. The hit
to the page is always counted. You then simply check that the javascript
hit count and the page hit counts are the same.
You will need to give the user a "free" visit or do an automatic redirect on
the first hit. If the JS count and the page hit counts don't match, JS is
disabled and you can display an error message to the user instead of the
content.
This can also be used for verifying that visitors are seeing your ads. You
simply devise a script that is called which displays the ad which also
counts the ad view. Ad views and hit counts then must match or the user is
blocked from seeing the content.
If javascript views are greater than page hits, then that's okay too since
it just means the main page is cached but the image is not.
If you can think of any circumstances under which this technique for
detecting javascript being enabled would fail, let me know.
And no, this is not being used on my own site...yet. Ad revenue from Google
AdSense is currently covering costs nicely so there's no reason to go after
people who block ads which results in cost to me with no chance of a return.
As a visitor, I have the right to object to your ads. As a site owner I
have a right to refuse service if you don't allow the ads to even display.
It's fair. I recognize that sites like my own cost money to survive.
Either ads can cover the bills or visitors can pay directly. I'd rather
find ways to ensure that ads cover the bills. I've found that visitors like
subscription fees a heck of a lot less than they like ads.
Ben Kucenski
www.icarusindie.com
Sample source included
This method requires that your pages are PHP enabled and you have mySQL.
Although I suppose you could also use PHP sessions (not cookies as they're
client editable). You could actually use any server side scripting language
such as Perl or ASP and any database like MS SQL Server. I prefer PHP and
MySQL.
The short version is you have a default image displayed and then use
javascript to replace the default image with a script reference. The
browser will then load that script which counts the javascript hit. The hit
to the page is always counted. You then simply check that the javascript
hit count and the page hit counts are the same.
You will need to give the user a "free" visit or do an automatic redirect on
the first hit. If the JS count and the page hit counts don't match, JS is
disabled and you can display an error message to the user instead of the
content.
This can also be used for verifying that visitors are seeing your ads. You
simply devise a script that is called which displays the ad which also
counts the ad view. Ad views and hit counts then must match or the user is
blocked from seeing the content.
If javascript views are greater than page hits, then that's okay too since
it just means the main page is cached but the image is not.
If you can think of any circumstances under which this technique for
detecting javascript being enabled would fail, let me know.
And no, this is not being used on my own site...yet. Ad revenue from Google
AdSense is currently covering costs nicely so there's no reason to go after
people who block ads which results in cost to me with no chance of a return.
As a visitor, I have the right to object to your ads. As a site owner I
have a right to refuse service if you don't allow the ads to even display.
It's fair. I recognize that sites like my own cost money to survive.
Either ads can cover the bills or visitors can pay directly. I'd rather
find ways to ensure that ads cover the bills. I've found that visitors like
subscription fees a heck of a lot less than they like ads.
Ben Kucenski
www.icarusindie.com