开发者

strange behavior history.back inside iframe

there is the page with two iframes:

<iframe src="fr1.html" name="fr1"></iframe>
<iframe src="fr2.html" name="fr2"></iframe

iframes contain code:

<a href="next_fr1.html">next<a/>
<div>frame 1</div>

and

<a href="next_fr2.html">next<a/>
<div>frame 2</div>

respectively.

开发者_StackOverflow社区

Pages next_fr1.html and next_fr2.html contain this code:

<a href="javascript:parent.frames.fr1.history.back();">back<a/>
<div>next frame 1</div>

and

<a href="javascript:parent.frames.fr2.history.back();">back<a/>
<div>next frame 2</div>

respectively.

On the first page i clicked:

  1. "next" in the first iframe
  2. "next" in the second iframe
  3. "back" in the first iframe

After 3rd click is back in the second iframe (as if back button in browser) and not back in the first iframe?


The frames doesn't have separate histories, the page holds the history for all frames also.

When you call history.back it goes to the previous step in the history of the page, so it will go back in the frame where the last navigation occured.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜