By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Loading page using browser's history

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.