/    Sign up×
Community /Pin to ProfileBookmark

History ignoring iFrames.

Hi there,

I got iFrames in my page and created a back button with Javascript (onclick=”window.history.go(-1)”). The back button isn’t placed in the iFrame.
Whenever I hit my back button it first skips through the history of the iFrames, then it follows the history of the main window. How can I let my back button only refer to the mian window and ignore the iFrames?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJul 27.2004 — An IFRAME has its own history, separate from all other histories. If you have an IFRAME named xyz, you would use
window.top.xyz.history.go(-1);
Copy linkTweet thisAlerts:
@samdeskinApr 19.2006 — I have two iframes on a page and I am trying to control the history of each one separately.

Giving the iframe a name and the back and forward buttons the same name seems to have screwed it up.... Any suggestions...

<div align="center"> <center> <table border="1" cellpadding="0" cellspacing="0" width="100%" height="85%" bordercolor="#000000"> <tr> <td width="50%">


<iframe align="center" width="100%" height="85%" src="http://google.com" frameborder=yes name="myIframe" id="myIframe"> </iframe>

<p align="center"><p align="center">


<input type="button" VALUE="<< Back" onClick="history.go(-1)">

<input type="button" VALUE="Forward >>" OnClick="history.go(1)">

<p></td><td width="50%">

<iframe align="center" width="100%" height="85%" src="http://microsoft.com" frameborder=yes name="myIframe2" id="myIframe"> </iframe>

<p align="center"><p align="center">

<input type="button" VALUE="<< Back" onClick="myIframe2.history.go(-1)">

<input type="button" VALUE="Forward >>" OnClick="myIframe2.history.go(1)">

</td> </tr> </table> </center></div>
Copy linkTweet thisAlerts:
@gil_davisJun 28.2006 — 
<input type="button" VALUE="<< Back" onClick="[color=red]history.go(-1)[/color]">

<input type="button" VALUE="Forward >>" OnClick="[color=red]history.go(1)[/color]">
[/quote]

You need to put "myIframe1." in front of the stuff in red.
×

Success!

Help @Aoi-kun spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...