IE9在加载iframe的脚本时抛出异常。为什么? [英] IE9 throws exceptions when loading scripts in iframe. Why?

查看:187
本文介绍了IE9在加载iframe的脚本时抛出异常。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

precondition:

Precondition:

我有iframe内ASPX页面。这IFRAME指向由MVC在同一地点处理的URL(这是混合动力的网站,无论是标准的ASP.NET和ASP.NET MVC)。通过MVC呈现的结果页面中含有大量的脚本引用。

I have an aspx-page with iframe inside. This iframe points to the url handled by MVC on the same site (it's hybrid site, both standard ASP.NET and ASP.NET MVC). The resulting page rendered by MVC contains a lot of scripts references.

问题:

IE9抛出的每一个脚本,它在iframe中加载一个例外。这些例外是类似这样的:

IE9 throws an exception on every single script it load in iframe. These exceptions are similar to this one:

Error: 'Function' is undefined

也就是说,它说,最基本的东西每个窗口都有不知何故缺席。一旦您完成所有这些弹出窗口点击,页面只是工作作为设计的!结果
如果我加载从URL < IFRAME /方式> 直接在浏览器src属性,一切都按预期结果
如果我在其他浏览器中打开页面(我试过歌剧,火狐),一切正常 - 没有错误

That is, it says that the most basic things every window has is somehow absent. Once you clicked through all of these popups, the page just works as designed!
If I load a URL from <iframe /> src attribute in the browser directly, everything works as expected.
If I open the page in another browser (I tried Opera, Firefox), everything works as expected -- no errors.

那么,什么都想IE9?

So, what IE9 wants?

推荐答案

有是的这个MSDN页面这个错误(或功能)。

There is this msdn page about this bug (or feature).

当你在DOM中移动iframe元素你得到这些类型的错误。在这种情况下,IE 9的垃圾收集IFRAME(导致您不确定的错误),并在另一位置重新加载。

You get these kinds of errors when you move the iframe element around in DOM. In such cases, IE 9 garbage collects the iframe (causing your undefined bug) and reloads it at another position.

在一般情况下,你应该创建元素,设置其的src 属性唯一的一次的,然后把它放在某处DOM树的一旦的。它无关,与它运行在iframe本身code。

In general, you should create the element, set its src attribute only once and then put it somewhere in the DOM tree once. It has nothing to do with the code which runs in the iframe itself.

这篇关于IE9在加载iframe的脚本时抛出异常。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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