RE: Distinguishing between a mouse click and a refresh?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 12/4/2006 01:08 PM, Jay Blanchard wrote:
[snip]
Is there any way for PHP to know whether it is being called due to a
browser refresh versus a mouse click?  I think the answer is no but I
just want to be sure.  Thanks.
[/snip]

Not unless you specifically capture and send a JavaScript onClick event.
A mouse click typically takes you somewhere else, so if you are using
for a page refresh you could capture and send a JavaScript variable to
the PHP script.


The tricky bit would be distinguishing between a page loaded with a mouse-click and a subsequent reload of that same page, as they would share the same querystring. One way would be to use javascript to supply the current absolute time in the querystring at the moment of click (you could do the same sort of thing with submit using a hidden field or a querystring appended to the form action), then PHP could compare that time with its own current time to see if the querystring represented a current or old rendering.

That would fail with javascript disabled, of course.

A server-side-only solution could pre-populate all the links on the site that point to this page with a special querystring. When the script/page is invoked with that querystring, PHP does the necessary processing and then redirects to itself (the same page) but without the special querystring. Therefore reloading the page that's downloaded to the client won't reinvoke the post-click process.

Regards,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux