重新加载 IFRAME 而不添加到历史记录 [英] Reload an IFRAME without adding to the history
问题描述
我正在更改 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屋!