"Mike" <Mi**@Ihatespam.leavemealonewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Is there a way to determine if a page was refreshed? I have a function
that
is called when the page loads, but when the user refreshes the page it
calls
the function again. Is there a way to call the function only when the page
initially loads? I don't want it to load when the user clicks the refresh
button.
If this is for a standard page GET then there is no absolutely reliable way
to determine whether the request is the result of refresh. The presence of
a Pragma: no-cache header is a clue but IE will often add that header to a
request for a page the first time its requested in a session also.
Setting a session cookie might help (make sure you set the cookie path to
the full path of your page). If the cookie is not present then it will be
the first time the request is being made. If it is then the request has
been made in that session before.
You might be able to combine the two to get something fairly reliable. If
the session cookie is present but pragma: no-cache isn't then the user has
navigated back to the page normaly without a refresh.
But then you need to consider other browsers, FF for example behaves in
somewhat more predictable way, and its fairly safe to test for
pragma:no-cache to detect a refresh.
--
Anthony Jones - MVP ASP/ASP.NET