From: Ed Jay on
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)
From: Randy Webb on
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/
From: Ed Jay on
Randy Webb <HikksNotAtHome(a)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)
From: Ivo on
"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


From: Sean Berry on

"Ed Jay" <edMbj(a)aes-intl.com> wrote in message
news:ja7hr15umr5vv4fb2bnv0200u17nc210vp(a)4ax.com...
> Randy Webb <HikksNotAtHome(a)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)