473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

page onload/refresh

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.
Apr 8 '08 #1
3 3996
Mike wrote on 08 apr 2008 in microsoft.public.inetserver.asp.general:
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 you mean a serverside function, as you should in this NG:

Yes, look for the referrer.
This is not serverside foolproof, as you use a browser header.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 8 '08 #2
"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
Apr 8 '08 #3
"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
Mike wrote on 08 apr 2008 in microsoft.public.inetserver.asp.general:
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 you mean a serverside function, as you should in this NG:

Yes, look for the referrer.


That won't help. A refresh pretty much repeats the original request,
therefore the referrer in a refresh will be the same same as in the original
navigation.

--
Anthony Jones - MVP ASP/ASP.NET
Apr 8 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Keith | last post by:
First I would question why you want to do this. If they get to the page by any means it should respond appropriately, whether refresh or by link. This is a stateless environment after all. That...
5
by: bissatch | last post by:
Hi, I have been trying to come up with an idea to reduce double submissions where a user clicks refresh and, for example, another row is INSERT into a table. Originally, I would have a form...
6
by: iwearwatches | last post by:
Group, What a root canal. Here is what I have: I have a page that has several layers that I will either show/hide based on a graphic/tab that the user clicks. (works perfectly)
5
by: Dan | last post by:
We have a simple site. It's a frameset with two frames a left and a right. The left frame is essentially a list of records from a database (using a server-side repeater control). When you click...
18
by: Alan Z. Scharf | last post by:
1. I have a chain of six asynch callbacks initiated by a button, and want the page to refresh at the end of each callback to display A. Results of a SQLServer query showing cumulative running...
0
by: Ambush | last post by:
My aspx is called from an ASP page. I process the request and then call another ASP page with a few hidden inputs. Currently, when the page processes, the user is complaining that my code is...
10
by: phforum | last post by:
Hi, I wrote a PHP page for user input the information to search the database. And the database data will update every second. I want to set the auto refresh to get the data from database every...
6
ak1dnar
by: ak1dnar | last post by:
Hi, I am developing a web site that displays Products, and along with each products there is a Button.There is a <DIV> in my page to display Number of Products Added to the Basket. Items : 0 ...
6
by: Chris Beall | last post by:
(I'm rather inexperienced with JavaScript; the failing page was cobbled together from multiple sources)... http://pages.prodigy.net/chris_beall/STL/Timeline.html If JavaScript is not present,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.