Welcome to WebmasterWorld Guest from 107.20.104.161

Forum Moderators: open

Message Too Old, No Replies

JavaScript back button for frames

Can anyone help me with a javascript to create a back button

     

kapow

12:42 pm on Apr 3, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can anyone help me with a javascript to create a back button on a framed website? I want a back button on my navigation frame but I want it to make the 'main page frame' go back. Can this be done??? I have this simple script but it only works within the same frame.

<a href="#" target="stage" onClick="history.go(-1)">Back</a>

katarina

1:56 pm on Apr 3, 2001 (gmt 0)

10+ Year Member



A frameset contains, as you already know, of two or more windows. Each can be dedicated a name when the frameset is opened. This name can be used when you want javascript to perform some kind of action on that page (parent.frames('nameOfWindow').history.back()).

If you haven't named your windows it is still possible to reach them by their position in the frameset.length array. "parent.frames[0].location.href" would change url of one of the framewindows. parent.frames[1] another and so on.

The frameset itself is the "parent" and very often also the "top" unless it is part of another frameset.

I believe, although I'm not 100% sure, that you can dedicate a name of the frameset itself, and reach it by using the name as in "myFrameName.history.back()".

Otherwise - try using "parent" or "top" before your action.

[developer.netscape.com...] explains very well how windows and frames should be referenced to as objects. Check the Client-Side JavaScript Reference documentation.

Good luck,
Katarina

kapow

3:45 pm on Apr 6, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Katarina - Thankyou for your expert help. It works perfectly.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month