我有一个网页,单击按钮会在 div 的 iframe 中加载另一个网页。单击启动按钮后,
- iframe 的 src 属性将设置为所需网页的 url。我注意到这会增加历史记录。
- 显示了 div,它本质上也显示了 iframe
单击关闭按钮时,
- div 被隐藏,这本质上隐藏了 iframe 以及
- iframe 的 src 属性设置为 about:blank,删除 iframe 对象
现在 没有帮助这个关闭部分增加了浏览器历史记录,我可以在历史记录列表中看到 iframe。为什么会发生这种情况以及如何避免这种情况?
我找到了解决方案。可以用新的 url 替换该位置,而不是设置源属性。示例:iframeobject.set contentWindow.document.location.replace(url);
I have a web page that on click of buttons loads another web page in iframe in a div. On clicking the launch button this is what is done
- the src attribute of iframe is set to url of required webpage. I have noticed this increments the history.
- the div is shown, which essentially shows the iframe as well
On clicking the close button
- the div is hidden, which essentially hides the iframe as well
- the src attribute of iframe is set to about:blank, deleting the iframe object doesn't help
Now this close part increases the browser history and I can see the iframe in history list. Why is this happening and how can I avoid this?
I found the solution. Instead of setting the source attribute one can replace the location with a new url. Example: iframeobject.set contentWindow.document.location.replace(url);
发布评论
评论(1)
解决历史问题的一种方法是不使用 iframe 而是使用对象并将其数据属性更改为任何目标。它不会添加到历史中,因为这就像更改图像的来源一样。您只需在对象标记
a way to fix the history thing is to not use an iframe but an object and change its data attribute to whatever target. it won't add to history because it's like changing the source of an image. you just have to specify
type="text/html"
in the object tag<object type="text/html" data="http://www.google.com/" width="500" height="500"></object>