I need to count how many times a div is viewed. Most hit counters count how many times a page is loaded but I want to count how many times a div is viewed. There are different pages that this div is located on and I need to know how many times it is viewed in total...regardless of what page it is viewed on. Please help!!!! I have spent 20hrs on this and I'm a newbie in desperation. Thanks.

有帮助吗?

解决方案

There are many php hit counter tutorials out there.

Heres one I found doing a google search:

https://code.google.com/p/simphp/

All you would have to do is call:

<? include("home/public_html/hits/simphp.php"); ?>

Then place this in the div you want counted:

<div id="count"><? echo $info; ?></div>

To detect if a div is visible in the browser window, use jQuery:

Check if div is viewable in window?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top