重新加载 IFRAME 而不添加到历史记录 [英] Reload an IFRAME without adding to the history

查看:49
本文介绍了重新加载 IFRAME 而不添加到历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更改 IFRAME 的 src 以重新加载它,它工作正常并在加载 HTML 时触发 onload 事件.

但是它在历史记录中添加了一个条目,这是我不想要的.有什么办法可以重新加载 IFRAME 而不影响历史记录吗?

解决方案

您可以使用 javascript location.replace:

window.location.replace('...html');

<块引用>

将当前文档替换为一个在提供的 URL.这与assign()方法的区别在于在使用 replace() 之后,当前页面不会保存在会话中历史,这意味着用户不会能够使用后退按钮导航到它.

I'm changing an IFRAME's src in order to reload it, its working fine and firing the onload event when its HTML loads.

But it adds an entry to the history, which I don't want. Is there any way to reload an IFRAME and yet not affect the history?

解决方案

You can use javascript location.replace:

window.location.replace('...html');

Replace the current document with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session history, meaning the user won't be able to use the Back button to navigate to it.

这篇关于重新加载 IFRAME 而不添加到历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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