473,239 Members | 1,584 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,239 software developers and data experts.

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 2633
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.javascript 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.referrer 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.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=$var1value&" if ($var1value);
$params .= "var2=$var2value&" if ($var2value);
.... etc ...
print "<a href=\"page1.pl?$params\">Page1</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.formName.action = pageToEdit;
document.formName.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.javascript 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**@buildingonline.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=$var1value&" if ($var1value);
$params .= "var2=$var2value&" if ($var2value);
... etc ...
print "<a href=\"page1.pl?$params\">Page1</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.formName.action = pageToEdit;
document.formName.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
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...
2
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...
15
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...
6
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...
4
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...
6
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...
3
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...
10
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...
2
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.