浏览器后退作用于嵌套的iframe页面本身之前 - 有没有办法避免呢? [英] browser back acts on nested iframe before the page itself - is there a way to avoid it?

查看:927
本文介绍了浏览器后退作用于嵌套的iframe页面本身之前 - 有没有办法避免呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些Ajax和JavaScript的大量装载动态数据的页面。

I have a page with dynamic data loaded by some ajax and lots of javascript.

页包含一个列表,用户可以选择和每个所选择的值加载新数据到页。

the page contains a list from which the user can choose and each selected value loads new data to the page.

其中的一个数据项是提供给一个iframe的URL。

One of these data items is a url provided to an iframe.

我用 jQuery的烧烤:后退按钮和放大器;查询库来模拟浏览器回的行为。

I use jQuery BBQ: Back Button & Query Library to simulate the browser-back behavior.

一切运作良好,除了当我点击后退按钮,第一次的iframe可以追溯到它的previous位置,然后我需要回去再次单击使页面回去的事实。

All works well besides the fact that when i click the back button for the first time the iframe goes back to its previous location and then I need to click back again to make the page go back.

有没有一种方法来禁用的iframe的背面行为?

Is there a way to disable the iframe's back behavior?

推荐答案


我已经找到了答案,我的问题想这可能是对别人有用的在那里。


I've found the answer to my problem guess it could be useful for others out there.

该问题是与我分配了新的URL到我的iframe的方式,我用jQuery的所以它看起来是这样的:

The problem was with the way i assigned new URLs to my Iframe, i used Jquery so it looked something like that:

$('#myIFrame').attr('src',newUrl);

当以这种方式指定的URL它增加了一个新条目访问的URL来回到浏览器的列表。
这是不是所需的行为,因此一些谷歌上搜索,我发现,你可以不将其加入了背列表指定一​​个新的URL的iframe对象之后,它看起来就像是:

When assigning the URL in that manner it adds a new entry to the browser's list of visited URLs to go back to.
That wasn't the desired behavior, so after some googling i found that you can assign a new URL to an Iframe object without adding it to the 'back-list', it looks like that:

var frame = $('#myIFrame')[0];  
frame.contentWindow.location.replace(newUrl);

这样我后退按钮行为完全符合预期。

This way my back button behave exactly as expected.

顺便说一句,我得到了我的回答从<一个href="http://www.ozzu.com/programming-forum/ignoring-iframes-with-javascript-history-t67189.html">here.

btw, i got my answer from here.

希望这是对您有所帮助,因为它是我的。

Hope this was helpful to you as it was to me.

这篇关于浏览器后退作用于嵌套的iframe页面本身之前 - 有没有办法避免呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆