473,581 Members | 3,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading page using browser's history

I want to use history.go() to navigate between my previously loaded pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?

Is there a method for detecting what page the user came from when a page
is accessed using history.go()?

--
Ed Jay (remove M to respond by email)
Jan 2 '06 #1
8 2657
Ed Jay said the following on 1/1/2006 9:29 PM:
I want to use history.go() to navigate between my previously loaded pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?
Just the normal events. But you can't tell how it was triggered.
Meaning, when page1.html is accessed, it has no means of knowing whether
it was loaded with the back button, the history.go or a direct link.
Is there a method for detecting what page the user came from when a page
is accessed using history.go()?


No.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 2 '06 #2
Randy Webb <Hi************ @aol.com> wrote:
Ed Jay said the following on 1/1/2006 9:29 PM:
I want to use history.go() to navigate between my previously loaded pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?
Just the normal events.


For example?
But you can't tell how it was triggered.
Meaning, when page1.html is accessed, it has no means of knowing whether
it was loaded with the back button, the history.go or a direct link.
That's not a problem for my application.
Is there a method for detecting what page the user came from when a page
is accessed using history.go()?


No.


I'm trying to write an editing routine for a multiple-page application.
Simple example:

Say I have three pages. The first two are 'data entry' pages and Page 3 is
a reporting page. I enter data in a form on Page 1 and submit it via CGI
to a script. On submitting the form, I set a flag on Page 1. The [Perl]
script reads the form from Page 1 and generates Page 2 in which more data
is entered in a form. This form is submitted, along with the data from
Page 1 (in hidden input elements), to Page 3.

From Page 3, if I want to edit something on Page 1, I use history.go(-2)
to navigate to Page 1 where I edit the data. On re-submitting Page 1, I
check to see if my flag is set. If it is, I go directly to Page 3. Of
course, when I reload Page 3 with the edited data from Page 1, I lose the
data previously entered on Page 2. Short of saving the data from Page 2 to
a file or in a cookie, I haven't been able to think of a way to reload
Page 3 without losing the data.

My path to a solution brings me to using history.go(2) on Page 1 to get to
Page 3 with its Page 2 data still intact, but how to update Page 3 with
the new Page 1 data? I can envision ways to bring the data to Page 3, but
I need something to let me know when Page 3 is available to receive the
edited data. I tried using onLoad() to call a script, but fetching the
page from the browser history didn't work. There doesn't seem to be an
onLoad event.

What's this poor newbie to do?

--
Ed Jay (remove M to respond by email)
Jan 2 '06 #3
Ivo
"Randy Webb" wrote
Ed Jay said
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?


Just the normal events. But you can't tell how it was triggered.
Meaning, when page1.html is accessed, it has no means of knowing whether
it was loaded with the back button, the history.go or a direct link.


There is one exception I believe. If the document.referr er property is set,
if it has a value, no matter what it is, you may conclude with certainty the
trigger was no script. Only ordinary links clicked and followed in the
ordinary way, result in setting the referrer in browser memory.
--
hth
ivo
http://www.ariel.shakespearians.com/
Thou shalt be free
Jan 2 '06 #4

"Ed Jay" <ed***@aes-intl.com> wrote in message
news:ja******** *************** *********@4ax.c om...
Randy Webb <Hi************ @aol.com> wrote:
Ed Jay said the following on 1/1/2006 9:29 PM:
I want to use history.go() to navigate between my previously loaded
pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?
Just the normal events.


For example?
But you can't tell how it was triggered.
Meaning, when page1.html is accessed, it has no means of knowing whether
it was loaded with the back button, the history.go or a direct link.


That's not a problem for my application.
Is there a method for detecting what page the user came from when a page
is accessed using history.go()?


No.


I'm trying to write an editing routine for a multiple-page application.
Simple example:

Say I have three pages. The first two are 'data entry' pages and Page 3 is
a reporting page. I enter data in a form on Page 1 and submit it via CGI
to a script. On submitting the form, I set a flag on Page 1. The [Perl]
script reads the form from Page 1 and generates Page 2 in which more data
is entered in a form. This form is submitted, along with the data from
Page 1 (in hidden input elements), to Page 3.

From Page 3, if I want to edit something on Page 1, I use history.go(-2)
to navigate to Page 1 where I edit the data. On re-submitting Page 1, I
check to see if my flag is set. If it is, I go directly to Page 3. Of
course, when I reload Page 3 with the edited data from Page 1, I lose the
data previously entered on Page 2. Short of saving the data from Page 2 to
a file or in a cookie, I haven't been able to think of a way to reload
Page 3 without losing the data.


Using PERL you could do something like the following (not my preference)
$params = "";
$params .= "var1=$var1valu e&" if ($var1value);
$params .= "var2=$var2valu e&" if ($var2value);
.... etc ...
print "<a href=\"page1.pl ?$params\">Page 1</a>";

So, you would pass all of the data from Page2 back to Page1. Then, on page
1 and 2 you do the same thing. Or you can use hidden inputs on your forms.

You would need to include all variables on each page so that they carried
through all the time no matter which page you go to.

What I would suggest is using something that is session aware, like Java.
Then, you could use a Java Bean to keep track of all of the data, no matter
what pages they went to and what data they filled out.


My path to a solution brings me to using history.go(2) on Page 1 to get to
Page 3 with its Page 2 data still intact, but how to update Page 3 with
the new Page 1 data? I can envision ways to bring the data to Page 3, but
I need something to let me know when Page 3 is available to receive the
edited data. I tried using onLoad() to call a script, but fetching the
page from the browser history didn't work. There doesn't seem to be an
onLoad event.

What's this poor newbie to do?

--
Ed Jay (remove M to respond by email)

Jan 2 '06 #5
Ed Jay said the following on 1/1/2006 10:46 PM:
Randy Webb <Hi************ @aol.com> wrote:

Ed Jay said the following on 1/1/2006 9:29 PM:
I want to use history.go() to navigate between my previously loaded pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?
Just the normal events.

For example?


onunload
onload in the loaded document

<snip>

I'm trying to write an editing routine for a multiple-page application.
Simple example:

Say I have three pages. The first two are 'data entry' pages and Page 3 is
a reporting page. I enter data in a form on Page 1 and submit it via CGI
to a script. On submitting the form, I set a flag on Page 1. The [Perl]
script reads the form from Page 1 and generates Page 2 in which more data
is entered in a form. This form is submitted, along with the data from
Page 1 (in hidden input elements), to Page 3.


Page 3 would have 3 buttons:

<input type="button" value="Edit Page 1" onclick="edit(' page1.html')">
<input type="button" value="Edit Page 2" onclick="edit(' page2.html')">
<input type="submit" value="Submit The Report">

Where the function edit would look something like this:

function edit(pageToEdit ){
document.formNa me.action = pageToEdit;
document.formNa me.submit();
}

It would submit the page to 3 possible places:

Page1
Page2
Final Page

Page1 would check to see if the fields from Page2 got submitted to it.
If they did, make the Action of the form point to Page 3 and set hidden
fields for data from Page2.

Page2 would only have to see if fields from Page2 got submitted and
re-populate the form fields and set the fields for Page1 in hidden fields.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 2 '06 #6
On 2006-01-02, Ed Jay <ed***@aes-intl.com> wrote:
Randy Webb <Hi************ @aol.com> wrote:
Ed Jay said the following on 1/1/2006 9:29 PM:
I want to use history.go() to navigate between my previously loaded pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?


Just the normal events.


For example?
But you can't tell how it was triggered.
Meaning, when page1.html is accessed, it has no means of knowing whether
it was loaded with the back button, the history.go or a direct link.


That's not a problem for my application.
Is there a method for detecting what page the user came from when a page
is accessed using history.go()?


No.


I'm trying to write an editing routine for a multiple-page application.
Simple example:

Say I have three pages. The first two are 'data entry' pages and Page 3 is
a reporting page. I enter data in a form on Page 1 and submit it via CGI
to a script. On submitting the form, I set a flag on Page 1. The [Perl]
script reads the form from Page 1 and generates Page 2 in which more data
is entered in a form. This form is submitted, along with the data from
Page 1 (in hidden input elements), to Page 3.

From Page 3, if I want to edit something on Page 1, I use history.go(-2)
to navigate to Page 1 where I edit the data.


Don't.
Re-generate a page 1 look-alike with hidden fields containing the page two
data. You could organise the fields on this fake page 1 so they look to
the perl like the fields on page 2

another way would be to store all the submitted data on the server.

Bye.
Jasen
Jan 2 '06 #7
"Sean Berry" <se**@buildingo nline.com> wrote:

"Ed Jay" <ed***@aes-intl.com> wrote in message
news:ja******* *************** **********@4ax. com...
Randy Webb <Hi************ @aol.com> wrote:
Ed Jay said the following on 1/1/2006 9:29 PM:
I want to use history.go() to navigate between my previously loaded
pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?

Just the normal events.
For example?
But you can't tell how it was triggered.
Meaning, when page1.html is accessed, it has no means of knowing whether
it was loaded with the back button, the history.go or a direct link.


That's not a problem for my application.

Is there a method for detecting what page the user came from when a page
is accessed using history.go()?

No.


I'm trying to write an editing routine for a multiple-page application.
Simple example:

Say I have three pages. The first two are 'data entry' pages and Page 3 is
a reporting page. I enter data in a form on Page 1 and submit it via CGI
to a script. On submitting the form, I set a flag on Page 1. The [Perl]
script reads the form from Page 1 and generates Page 2 in which more data
is entered in a form. This form is submitted, along with the data from
Page 1 (in hidden input elements), to Page 3.

From Page 3, if I want to edit something on Page 1, I use history.go(-2)
to navigate to Page 1 where I edit the data. On re-submitting Page 1, I
check to see if my flag is set. If it is, I go directly to Page 3. Of
course, when I reload Page 3 with the edited data from Page 1, I lose the
data previously entered on Page 2. Short of saving the data from Page 2 to
a file or in a cookie, I haven't been able to think of a way to reload
Page 3 without losing the data.


Using PERL you could do something like the following (not my preference)
$params = "";
$params .= "var1=$var1valu e&" if ($var1value);
$params .= "var2=$var2valu e&" if ($var2value);
... etc ...
print "<a href=\"page1.pl ?$params\">Page 1</a>";

So, you would pass all of the data from Page2 back to Page1. Then, on page
1 and 2 you do the same thing. Or you can use hidden inputs on your forms.

You would need to include all variables on each page so that they carried
through all the time no matter which page you go to.


I've considered doing almost exactly as you suggest. I still may
experiment with it. The only issue I can see is that in reality, I have 7
pages of input and I've been concerned about how long it might take.
What I would suggest is using something that is session aware, like Java.
Then, you could use a Java Bean to keep track of all of the data, no matter
what pages they went to and what data they filled out.
I think a hidden frame as a scratch pad would be more viable. I'm
concerned over statements I've read that when using frames, history.go()
isn't reliably implemented.
My path to a solution brings me to using history.go(2) on Page 1 to get to
Page 3 with its Page 2 data still intact, but how to update Page 3 with
the new Page 1 data? I can envision ways to bring the data to Page 3, but
I need something to let me know when Page 3 is available to receive the
edited data. I tried using onLoad() to call a script, but fetching the
page from the browser history didn't work. There doesn't seem to be an
onLoad event.

What's this poor newbie to do?

--
Ed Jay (remove M to respond by email)

Thanks for the suggestions.

--
Ed Jay (remove M to respond by email)
Jan 2 '06 #8
Randy Webb <Hi************ @aol.com> wrote:
Ed Jay said the following on 1/1/2006 10:46 PM:
Randy Webb <Hi************ @aol.com> wrote:

Ed Jay said the following on 1/1/2006 9:29 PM:

I want to use history.go() to navigate between my previously loaded pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?

Just the normal events.

For example?


onunload
onload in the loaded document

I'm sure onUnload will work. I've proven to myself that onLoad() doesn't.
If it did, I think my problem would be solved.

I'm trying to write an editing routine for a multiple-page application.
Simple example:

Say I have three pages. The first two are 'data entry' pages and Page 3 is
a reporting page. I enter data in a form on Page 1 and submit it via CGI
to a script. On submitting the form, I set a flag on Page 1. The [Perl]
script reads the form from Page 1 and generates Page 2 in which more data
is entered in a form. This form is submitted, along with the data from
Page 1 (in hidden input elements), to Page 3.


Page 3 would have 3 buttons:

<input type="button" value="Edit Page 1" onclick="edit(' page1.html')">
<input type="button" value="Edit Page 2" onclick="edit(' page2.html')">
<input type="submit" value="Submit The Report">

Where the function edit would look something like this:

function edit(pageToEdit ){
document.formN ame.action = pageToEdit;
document.formN ame.submit();
}

It would submit the page to 3 possible places:

Page1
Page2
Final Page


The above scheme is exactly what I have.
Page1 would check to see if the fields from Page2 got submitted to it.
If they did, make the Action of the form point to Page 3 and set hidden
fields for data from Page2. Page2 would only have to see if fields from Page2 got submitted and
re-populate the form fields and set the fields for Page1 in hidden fields.


An interesting approach. Thanks...I'll pursue it.

--
Ed Jay (remove M to respond by email)
Jan 2 '06 #9

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

Similar topics

4
3120
by: Tim Marsden | last post by:
Hi, If I navigate from Page1 to Page2 then to Page3, using the response.redirect. When the user press the Back button, I what then to go to Page 1 and start again, not Page2. I dont want the to navigate to Page2 using the Back and Forward buttons. How do I do this.
2
2327
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost when pulling data from an SQL database. The thing that frustrates me the most, is that when I use Enterprise Manager, the carriage returns ARE...
15
4740
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is...
6
5792
by: Coleen | last post by:
Hi all :-) I need to redirect to multiple pages on click of a transmit button, without redisplaying each page. This redirection is to capture session variables that are created on each page and pass them to the main page to be displayed. We are actually NOT using session variables, but storing the values in a temporary table. The problem...
4
2817
by: Scott Shuster | last post by:
Hi, I've been searching and testing and have not yet found the answer I'm looking for. I have an ASP.NET (vb) application with an ecommerce function. When the user submits the page, I DON'T want them to be able to click on the 'BACK' button and get back to the form - they may inadvertently re-submit the page and get charged again. I...
6
5070
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has a button EDIT ,which when user clicks directs him to another page (done.asp). Now the problem is that from this page (done.asp) if he clicks on the...
3
5286
by: laryten | last post by:
Hi, Is there a way to update the same web page instead of getting a new page each time we click the submit button? The simplest thing to do is to delete the current page (or go back to the previous page) and then redraw the page. There are a few possible solutions: 1. Use the same URL again. But a new page will still be created. 2. Use...
10
10405
Ajm113
by: Ajm113 | last post by:
Making a History Page for BIG Sites Intro: Ok, let's say after a while your website has grown massive. We're talking search engine, forum and video hosting -- you've got a LOT of content. And you are wondering, "Why do I need yet another feature for my big site?" Well, some people can become forgetful every time they see content on your...
2
3309
by: Max | last post by:
I recently moved to ASPnet Ext 3.5 What I can't get with Ajax and History browser managemet is this: User fills some fields (dropdown and textbox) on page 1 (all are in an update panel) User clicks Submit Button I write the data into a DB I add a history point with ScriptManager to be able to get back to this point with browser back...
0
7886
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...
0
7809
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8159
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. ...
0
8183
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6569
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...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1413
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
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...

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.