473,503 Members | 1,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is there a way to understand if a page is navigated by pressing back ?

I show errors as popup boxes via alert() but I write this scripts in header
of html page.So if there is an error on the server side , in the next
postback a popup shows the error via alert , this works fine.But when user
presses the back button then the former error messages appear ,because pages
are loaded from the cache.I need to find a way in javascript if a page is
loaded from server or navigated to page by pressing back or forward
buttons.Is there a property or anything that I can do ?
Nov 19 '05 #1
2 1682
There are a couple of things you could try:

You won't be able to 'disable' the back button per se but rather take an
appropriate action upon detecting its use. To detect its use you can try
either a client or server side approach depending on your needs.

The back button does not map to a JavaScript DOM event. However, you can
trap the 'onload' event of the body tag and take the appropriate action
which effectively gives you the same thing.

Alternatively, on the server side, you can disable output caching using a
page directive in your aspx's thus:

<%@ OutputCache Location="None" %>

Disabling the output cache forces the browser to retreive the page again
from the server which the server can detect and handle as appropriate.
Without it the server will not receive any notification that the end-user
just navigated.

Most web MVC frameworks have support for this type of navigation problem,
along with bookmarking random pages (and hence jumping around) your website,
typing in and navigating to a random URL, use of the back button etc. In
most cases the solution requires the use of stateful URLs. The Microsoft
User Interface Process v2 application block has rudimentary back button
support.

The only form of 'disablement' I can think of that you can do is catch all
user keystrokes client side, like 'ALT-<leftarrow>' (which is the moral
equivalent of hitting the back button), by using

setCapture() and treating it as a no-op.

"Ersin Gençtürk" <ers[spam]@gencturk.org> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
I show errors as popup boxes via alert() but I write this scripts in header
of html page.So if there is an error on the server side , in the next
postback a popup shows the error via alert , this works fine.But when user
presses the back button then the former error messages appear ,because
pages
are loaded from the cache.I need to find a way in javascript if a page is
loaded from server or navigated to page by pressing back or forward
buttons.Is there a property or anything that I can do ?

Nov 19 '05 #2
hi jeff,

thanks for the reply.I forgot but it is not a solution for my case to
disable the cache.On the other hand, I put a onload event on body and
pressed back button of the browser , page came from the cache but also the
onload event fired again.Am I doing something wrong ?

"Jeff B" <je*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
There are a couple of things you could try:

You won't be able to 'disable' the back button per se but rather take an
appropriate action upon detecting its use. To detect its use you can try
either a client or server side approach depending on your needs.

The back button does not map to a JavaScript DOM event. However, you can
trap the 'onload' event of the body tag and take the appropriate action
which effectively gives you the same thing.

Alternatively, on the server side, you can disable output caching using a
page directive in your aspx's thus:

<%@ OutputCache Location="None" %>

Disabling the output cache forces the browser to retreive the page again
from the server which the server can detect and handle as appropriate.
Without it the server will not receive any notification that the end-user
just navigated.

Most web MVC frameworks have support for this type of navigation problem,
along with bookmarking random pages (and hence jumping around) your website, typing in and navigating to a random URL, use of the back button etc. In
most cases the solution requires the use of stateful URLs. The Microsoft
User Interface Process v2 application block has rudimentary back button
support.

The only form of 'disablement' I can think of that you can do is catch all
user keystrokes client side, like 'ALT-<leftarrow>' (which is the moral
equivalent of hitting the back button), by using

setCapture() and treating it as a no-op.

"Ersin Gençtürk" <ers[spam]@gencturk.org> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
I show errors as popup boxes via alert() but I write this scripts in header of html page.So if there is an error on the server side , in the next
postback a popup shows the error via alert , this works fine.But when user presses the back button then the former error messages appear ,because
pages
are loaded from the cache.I need to find a way in javascript if a page is loaded from server or navigated to page by pressing back or forward
buttons.Is there a property or anything that I can do ?


Nov 19 '05 #3

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

Similar topics

16
15714
by: Dave Smithz | last post by:
Hi, In summary: I want to a form to submit information via a HTTP POST, however, when using Internet Explorer I want to be able to use the back button and all the information retained....
1
2776
by: Robert Oschler | last post by:
I know how to load a document into the "Search" panel/sidebar in Internet Explorer. I also know that I can use the "window.opener" property, from the "Search" sidebar document, to change the main...
31
3011
by: wallster | last post by:
please keep the flaming to a minimum (a bucket of water is next to me) but I have a question someone here might be able to explain in basic terms for a dunce like me. I helped a friend put...
2
1447
by: Lumpierbritches | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. Is there a way to know which form was navigated from when opening a form with a command button, and then to renavigate...
1
247
by: dhurwitz | last post by:
Hi I have developed a web app with a dozen or so pages, which allows searching for and editing orders by OrderID. There is a search page for entering multiple search criteria. In addition, each...
4
1262
by: interuser | last post by:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="pagexxx.aspx.vb" Inherits="pagexxx"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- #include...
1
1496
by: yasin | last post by:
is it possible that pressing "previous page"(back) button of web browser by code ?
28
2650
by: laredotornado | last post by:
Hi, Surprisingly, I can't get the drop down menus to work on PC IE 6. If you roll over "PRODUCTS", normally a drop down menu appears (on Safari and Firefox), but on PC IE, nada. ...
0
741
by: ayush patel | last post by:
Hi everyone, I have a question about maintaining the state of the page in a web application. I am not that aware of what should be done here. I want the page to retain all its values when user...
0
7203
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
7282
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,...
0
7339
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...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5017
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...
0
3168
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...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
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...

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.