You are here: irt.org | FAQ | JavaScript | Bookmark | Q174 [ previous next ]
The simple answer is that you can't, as JavaScript cannot interact with the browsers bookmarking functionality. This inability to bookmark a frame is one of the biggest drawbacks with frames. As adding a bookmark simple bookmarks the location of the frameset document.
There is however be a way around this if you don't mind reloading the frameset each time that a link is chosen. The reloading of the frameset is obviously less attractive than simply changing the location of one frame, but as the frameset is already loaded in the browsers cache then it'll load extremely quickly.
The basis for the following is taken from the existing article Re-directing access within Frames #2.
Say for example you have a frameset like this called top.html:
<FRAMESET COLS="50%,50%"> <FRAME SRC="frameA.html" NAME="nav"> <FRAME SRC="frameB.html" NAME="display"> </FRAMESET>
Then it needs to be changed to this top.html:
<HTML> <SCRIPT LANGUAGE="JavaScript"><!-- document.write('<FRAMESET COLS="50%,50%">'); document.write('<FRAME SRC="frameA.html" NAME="nav">'); document.write('<FRAME SRC="' + (location.search ? location.search.substring(1):"frameB") + '.html" NAME="display">'); document.write('<\/FRAMESET>'); //--></SCRIPT> </HTML>
What this does is accept a string passed in the locations search property, and loads that document instead of the dummy.html document in the display frame.
Then when adding a link to a page, instead of using:
<A HREF="frameC.html">go somewhere</A>
Use:
<A HREF="top.html?frameC" TARGET="_top">go somewhere</A>
Then when the person bookmarks the frameset, instead of bookmarking top.html they bookmark top.html?frameC, which will enable them to return exactly to where they were when they bookmarked the frameset.
Note: It will not work offline in Internet Explorer 3, but it will when placed online.