如何防止将iframe页面插入IE浏览历史记录中 [英] How To Prevent Iframe Pages Being Inserted Into IE Browsing History

查看:443
本文介绍了如何防止将iframe页面插入IE浏览历史记录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将iframe页面插入IE9的浏览历史记录时遇到了很多麻烦。这很痛苦,因为你必须多次点击才能进入上一页。这是什么原因?这是浏览器或页面中的错误吗?

I'm having a lot of trouble with iframe pages being inserted into the browsing history of IE9. It's a pain because you have to click back several times in order to get to the previous page. What is the cause of this? Is it a bug in the browser or the page?

编辑:
我意识到我正在使用javascript更新页面上所有iframe的来源添加wmode = transparent属性。

I realized I was using javascript to update the source of all iframes on the page to add the wmode=transparent attribute.

$('iframe').each(function () {
    var url = $(this).attr("src")
    $(this).attr("src", url + "?wmode=transparent");
 });

这已添加到战斗菜单导航中,落后于YouTube视频。有没有办法阻止IE将这些事件插入历史记录?

This was added to combat menu navigations were going behind YouTube videos. Is there a way to prevent IE from inserting these events into the history?

推荐答案

一个选项是替换iframe而不是更新源。

An option would be to replace the iframe rather than update the source.

$('iframe').each(function () {
   var url = $(this).attr("src")
   //$(this).attr("src", url + "?wmode=transparent");

   url = url + "?wmode=transparent";

   var frm = document.createElement("iframe");
   frm.src = url;
   //copy attributes of this -> frm
   $(this).replaceWith(frm);
});

任何iframe的src属性在插入DOM后都会被修改的历史记录条目。如果您无法控制iframe(第三方iframe)的内容,那么如果他们以任何方式修改其页面的位置,则会创建历史记录条目。

A history entry is made any time an iframe's src attribute is modified after it has been inserted into the DOM. If you aren't in control of the contents of the iframe (a third party iframe), then if they modify the location of their page in any way a history entry will be created.

这篇关于如何防止将iframe页面插入IE浏览历史记录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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