Forum Moderators: open

Message Too Old, No Replies

Browser history malfunctions on iframe page

Custom back button loses history when I click on the link

         

blue9217

10:33 pm on Jul 26, 2004 (gmt 0)

10+ Year Member



I have a website that contains iframes and links to other pages that I have created. One link that I have brings up a second page with a plugin and a back button I created. When I click on the back button on the second page, it indeed returns me to the page I was viewing beforehand but it resets the iframes to their original configuration, as well as the links I have established. On the original webpage, the iframes and some links get reset by other links on the same page. When I looked at the browser history on the second page, it didn't contain any of the previous pages that I had viewed. I would like to be able to have the iframes and especially the links remain how they were when the user left the page with the link, but I have no clue how to do this.

kaled

12:08 am on Jul 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to post the simplest possible version of the code you are using otherwise no one will be able to help you.

Also, if I understand you correctly, a generic solution may be very tricky - you may have to resort to page-specific javascript to make it work correctly across different browsers.

Kaled.

tedster

1:16 am on Jul 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, blue9217.

I think kaled has it right. Various browsers implement their history function differently around iframes.

In order to get consistent results of the kind you want, it will take scripting -- either client-side or more dependably, server-side (see our Javascript, PHP or Perl forums for more help in this direction.)

If you care about preserving more than the most recent state of that page, things may get very complex.

blue9217

4:06 pm on Jul 27, 2004 (gmt 0)

10+ Year Member



Here is the most basic code from my original page, it is the result of a processed form.

[pre]
<HTML>
<HEAD><TITLE> My Page </TITLE>
<SCRIPT language="JavaScript">
<!-- Begin
function loadpgs (page1,page4,page5) {
(I1.location.href=page1);
(MAG.href=page4);
(SAVE.href=page5);
}
-->
</SCRIPT>
<table width="214">
<td width="212"><iframe name="I1" src="HTML/1_min.html" width="200" height="200"
border="0" frameborder="0" scrolling="no"></iframe>
</td>
<td><a name="MAG" width="20" height="20"
href="HTML/1_mag.html">
<img src="ICON/magglasswht.gif" width="40"
height="40"></a>
<br>
<a name="SAVE" href="IMG/JNK.1090883375_0_1d.mol2">
<img src="ICON/save2.gif" width="40" height="40"></a></td>
<td><a href="javascript:loadpgs('HTML/1_min.html','HTML/1_mag.html',
'IMG/JNK.1090883375_0_1d.mol2')">Solution 1</a></td>
<td><a href="javascript:loadpgs('HTML/2_min.html','HTML/2_mag.html',
'IMG/JNK.1090883375_0_2d.mol2')">Solution 2</a></td>
</tr>
</table>
[/pre]

The second page is:


[pre]
<html>
<head>
<Title>1 Magnified</TITLE>
</head>
<body>
<EMBED type="chemical/x-mdl-molfile" color3D="cpk"
width="600" height="600" style="position:absolute;
top:0; left:0;" src="../IMG/flexx_XXX.1090883375_0_1d.mol2.mol"
script="select (atomno<=71); wireframe 40; spacefill
120; color cpk">
<LABEL style="position: absolute; left: 620; top: 50;
width:130; height:30;">Complex 1</LABEL>
<form>
<input type="button" value="Back to Results"
style="position:absolute; top:100; left:620; width:
130;" onClick="history.back()">
</form>
</body>
</html>
[/pre]

On the second page the EMBED tag is for the MDL Chime Pro plugin which allows me to display a chemical file. This webpage will only be viewed in IE6 cause the plugin only functions in IE6. The problem lies in the fact that when I click on the "Solution 2" link on the original webpage, and then click the "Back to Results" button on the second page, the two links, "MAG" and "SAVE" get reset to the first solution, instead of being set to the second solution, like they were when I left the original page. I hope that clears things up. Thanks!

kaled

4:39 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, I think I see what you're trying to do.

You need to store the state of the first page so that it can be restored later. The page itself should read the stored data and restore the state when it has loaded.

So you're left with chosing a method of storing some data temporarily.
The obvious choices are :-
1) Cookie
2) A zero-width sister frame. (I think you can access script vars in other frames - never tried it).

So far as I am aware, browsers don't provide any other means of storing data temporarily.

Hope this helps,

Kaled.

blue9217

11:52 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



Is there a way that I can reset what MAG and SAVE reference from the 'Back to Results' button that I have created? So for instance, when the 'Back to Results' button is pressed it calls a script or something that will reset the two links and not rely on the history of the page?

kaled

12:23 am on Aug 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, I've never tried setting the href value of a link using javascript, but I guess it's possible. I don't have my javascript book to hand at the moment but I guess document.MAG.href=whatever.html would work. HOWEVER, if you plan to change the document.location value as well, I don't think this approach will work unless called from another frame/window.

Kaled.