473,811 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4015
Mike wrote on 08 apr 2008 in microsoft.publi c.inetserver.as p.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 .leavemealonewr ote in message
news:%2******** ********@TK2MSF TNGP04.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.net wrote in message
news:Xn******** ************@19 4.109.133.242.. .
Mike wrote on 08 apr 2008 in microsoft.publi c.inetserver.as p.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
1702
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 being said... I would take the approach of setting a session variable that gets set the first time they hit the page:
5
3775
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 page. When a user submits the form (ie. index.php), I would script it so that when the form action would be the same page but it would use the address 'index.php?action=add'. This is bad (mmm-kay) as when the user refreshes the page it would add...
6
3993
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
2425
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 on one of the items in the left frame, it targets the right frame and displays a form prefilled with information for the item you clicked. The problem is the left frame's list just shows the names of the items, and the name of the item is...
18
10148
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 time, and B. A progress bar. 2. I have this working with a refresh timer: <META http-equiv="refresh" content="5">
0
1237
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 running too fast and that my "Please Wait" page flashes by too quickly. I can't put an inline wait/sleep command, as the page doesn't refresh until the code is done running. I've tried using a: <meta id="mtaRefresh" http-equiv="refresh"...
10
32890
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 minute. But the page always display the dialog box ask me to resend the information. How to disable this warning message. I using POST and REQUEST to get the data from user input page. Thanks all
6
2317
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 When user comes to the page, items will display as 0. if click the Button along with the product items will set to 1. Again user can click product only one time. Like wise for each and every onclick my Ajax function will fire. This is how it works:...
6
1841
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, or CSS 2 isn't supported, the page just shows a complete list of dated entries. That's correct. If JavaScript is present and CSS 2 is supported, a subset of the list is shown (Example: 9 Jan 2008 is absent) and a button appears in the upper
0
9727
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10398
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.