Last Comment Bug 168150 - history.go(location) isn't implemented
: history.go(location) isn't implemented
Status: NEW
:
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: Trunk
: All All
: -- normal with 2 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
http://devedge.netscape.com/library/m...
: 273655 275455 279119 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2002-09-12 02:34 PDT by Jam
Modified: 2009-08-22 20:52 PDT (History)
9 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Jam 2002-09-12 02:34:06 PDT
User-Agent:       Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1) Gecko/20020826
Build Identifier: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1) Gecko/20020826

Three example files were needed:

--- test1.htm -------------------------------------------
<head>
<title></title>
<script language="JavaScript1.2"><!--
var Stack    = new Array();
var StackPos = 0;
alert("test1.htm set up");
function Mark() {
 Stack[StackPos++] = hugo.location.href;
}
function Rosie() {
 hugo.history.go(Stack[--StackPos]);
//#WORKS#  hugo.location = Stack[--StackPos];
}
//--></script>
</head>
<frameset ROWS="100%,*" BORDER="0" FRAMEBORDER="0">
<FRAME SRC="./test2.htm" SCROLLING="AUTO" NORESIZE Name=hugo>
</FRAMESET>
<noframes>
<b>This is file test1.htm - please turn on your frame support!</b>
</noframes>
</html>
--- EOF -------------------------------------------------

--- test2.htm -------------------------------------------
<html>
<head>
<title></title>
<script>
parent.Mark();
</script>
</head>
<b>
This is file test2.htm - Please hit <a href="./test3.htm">here</a> to load
test3.htm...
</b>
</html>
--- EOF -------------------------------------------------

--- test3.htm -------------------------------------------
<html>
<head>
<title></title>
</head>
<b>
This is file test3.htm - Please hit <a
href="javascript:parent.Rosie();">here</a> to return to test2.htm...
</b>
</html>
--- EOF -------------------------------------------------

With this construction, I should be able to switch between test2 und test3.
Under NetScape 4.75 everything works fine, but Mozilla has probs. I've added a
#WORKS# comment which shows, how I can get it working, but the problem with that
solution is, that the history buffer is filled up with mess (which I don't want
to happen).

Any suggestions?

Reproducible: Always

Steps to Reproduce:
See description

Actual Results:  
I can't switch back to an previously loaded frame.

Expected Results:  
Load the frame from the history and clean up the history buffer
Comment 1 Phil Schwartau 2002-09-12 10:40:59 PDT
Browser, not engine ---> History: Session
Comment 2 Michael Lefevre 2002-12-05 05:12:59 PST
reporter (Jam): can you reproduce this bug with a recent build of mozilla (for
example, 1.2.1)? if so, please comment again with details (attaching a testcase
to the bug would make it easy to see how this works). if not, please resolve
this bug as WORKSFORME. thanks.
Comment 3 Jam 2002-12-09 03:58:57 PST
I tested it with 1.2.1. If you copy the text between the "-----" into the the
given files names (in the same directory) and loads test1.htm into the browser,
then you'll see

1. a popup-window appearing and informing, that test1.htm is set up (javascript)
proberly
2. see a text which informs, that test2.is currently active and you can hit the
link to go to test3.htm
3. then you'll get a message from test3.htm with a link to go back to test2.htm
4. hitting the link should reload test2.htm (so you can switch forth and back
between test2.htm and test3.htm). this works e.g. with netscape 4.xx but not
with any modzilla version.

Hope that helps
Jam
Comment 4 Boris Zbarsky [:bz] 2004-02-14 20:18:06 PST
history.go() is a function that takes a _number_ to go to in session history,
relative to the current page.  E.g. history.go(-1) to go back one page.

So what you're doing is in fact not supposed to work; I wonder why you decided
that it should...
Comment 5 timeless 2004-02-15 21:17:34 PST
go
Loads a URL from the history list.

Method of
	

History

Implemented in
	

JavaScript 1.0

Syntax

go(delta)
go(location)

Parameters

delta

	

An integer representing a relative position in the history list.

location

	

A string representing all or part of a URL in the history list.

Description
The go method navigates to the location in the history list determined by the
specified parameter.

If the delta argument is 0, the browser reloads the current page. If it is an
integer greater than 0, the go method loads the URL that is that number of
entries forward in the history list; otherwise, it loads the URL that is that
number of entries backward in the history list.

The location argument is a string. Use location to load the nearest history
entry whose URL contains location as a substring. Matching the URL to the
location parameter is case-insensitive. Each section of a URL contains different
information. See Location for a description of the URL components.

The go method creates a new entry in the history list. To load a URL without
creating an entry in the history list, use Location.replace.

Examples
The following button navigates to the nearest history entry that contains the
string "home.netscape.com":

<P><INPUT TYPE="button" VALUE="Go"
   onClick="history.go('home.netscape.com')">

The following button navigates to the URL that is three entries backward in the
history list:

<P><INPUT TYPE="button" VALUE="Go"
   onClick="history.go(-3)">

See also
History.back, History.forward, Location.reload, Location.replace
Comment 6 Boris Zbarsky [:bz] 2004-02-15 21:23:26 PST
Aiee.

Punting over to DOM, I guess, to decide whether we want to support that....
Comment 7 Kevin Brannen 2004-03-07 20:27:02 PST
Bummer this is here.  I ran into the need for this badly today (using Moz 1.6).
 It is part of the JS 1.1 standard, at least according to my O'Reilly JS book;
so I don't understand the comment "Punting over to DOM, I guess, to decide
whether we want to support that".  I suppose I'm assuming standard compliance is
good, but isn't the only decision "when" or "what priority"?

Pretending that I can carve out time for this, can someone point me to the
proper directory where the history object code would be found? (or at least get
me close :-)
Comment 8 Boris Zbarsky [:bz] 2004-03-07 20:34:44 PST
Actaully, the Window object is not part of any standard... and JS 1.1 is not a
standard, just a version of a language (of which Window is NOT a part).

For anyone who feels like working on this, what would need to happen is that
http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsHistory.cpp#243
(HistoryImpl::Go()) would need to detect a string argument in addition to the
numeric one it detects now and it would need to call LoadURI on the
webnavigation object the way HistoryImpl::Go(PRInt32 aDelta) does.

Then nsSHistory::LoadURI would need to be implemented in some way at
http://lxr.mozilla.org/seamonkey/source/xpfe/components/shistory/src/nsSHistory.cpp#635
(and deal with frames somehow... great fun).
Comment 9 Bill Deady 2004-09-14 12:39:02 PDT
I have an exit script which works in Netscape 7, IE6, which returns the user
back to the original login page.  

<script>
var loc1 = location.href;
var endp = loc1.search(/logout/gi);
var loc2 = loc1.substr(0,endp) + "index.asp" ;
history.go(loc2)
</script>

renders the equivalent of history.go("http://10.1.1.1/index.asp")
Have a new customer who wants to use FireFox as their default browser.  My exit
script won't work for him.  Otherwise, everything else works great.


Comment 10 kevin.haynes 2004-11-27 11:16:07 PST
(In reply to comment #9)
> I have an exit script which works in Netscape 7, IE6, which returns the user
> back to the original login page.  
> 
> <script>
> var loc1 = location.href;
> var endp = loc1.search(/logout/gi);
> var loc2 = loc1.substr(0,endp) + "index.asp" ;
> history.go(loc2)
> </script>
> 
> renders the equivalent of history.go("http://10.1.1.1/index.asp")
> Have a new customer who wants to use FireFox as their default browser.  My exit
> script won't work for him.  Otherwise, everything else works great.
> 
> 
> 


If you are using ASP your could try this:

onClick="window.location='<%=Request.ServerVariables("HTTP_REFERER")%>'"
Comment 11 Kevin Brosnan 2004-12-10 05:41:40 PST
*** Bug 273655 has been marked as a duplicate of this bug. ***
Comment 12 Phil Ringnalda (:philor) 2004-12-20 17:23:01 PST
*** Bug 275455 has been marked as a duplicate of this bug. ***
Comment 13 Phil Ringnalda (:philor) 2004-12-20 17:32:01 PST
Wouldn't doing this leak history a tiny bit? In IE,

window.history.go('http://www.mozilla.org/');
window.setTimeout("alert('clean')",2000);

tells you whether someone has been traitorous in that session (assuming, of
course, that instead of an alert it's an XMLHttpRequest resending a login cookie
to identify who hasn't been bad).
Comment 14 Kevin Brosnan 2005-01-20 06:53:06 PST
*** Bug 279119 has been marked as a duplicate of this bug. ***
Comment 15 Jonas Sicking (:sicking) No longer reading bugmail consistently 2006-04-05 02:21:39 PDT
(In reply to comment #13)
> Wouldn't doing this leak history a tiny bit?

Yeah, that was my first thought too. Though admittedly I was searching for a reason not to implement this :)

In any case, there doesn't seem to be a whole lot of sites out there that use this.

Regarding comment 10: You could simply do   window.location = loc2;

Note You need to log in before you can comment on or make changes to this bug.