我在服务器上使用ASP.NET 4.5,我有一个.NET Windows应用程序,它有一个Windows控件,可以导航到服务器上的网页。
如果我在一个使用Internet 11的系统上运行Windows应用程序,我会得到一个脚本错误:"Object不支持属性或方法'attachEvent'“当导航到另一个页面时。脚本文件是ScriptResource.axd,所以它不是我的任何脚本。
我知道Internet 11不再支持attachEvent (用attachEventListener?)。但是,这在这里没有多大帮助,因为javascript是框架的一部分,而不是我的代码。
我在这里找到了框架的javascript源代码:http://ajaxcontroltoolkit.codeplex.com/SourceControl/latest#Client/MicrosoftAjax/Extensions/Sys/WebForms/PageRequestManager.js
// DevDiv Bugs 100201: IE does not set referrer header on redirect if you set window.location, inject anchor node instead
// dynamic anchor technique only works on IE
if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
var anchor = document.createElement("a");
anchor.style.display = 'none';
// cancel bubble so body.onclick is not raised
anchor.attachEvent("onclick", cancelBubble);
// more code...
}据我所知,这是Sys.Webforms.PageRequestManager模块,它是核心ASP.NET框架的一部分。
执行attachEvent的行在Internet 11上会出现脚本错误,但在较旧版本的Internet上工作得很好。
如何解决这个问题?有什么已知的解决办法吗?我不能对这件事做任何更新。
发布于 2013-11-12 14:36:39
试着强迫浏览器在IE10模式下呈现.
<meta http-equiv="X-UA-Compatible" content="IE=10" />发布于 2014-02-19 09:00:53
我在jQuery 1.10中遇到了这个问题,而且看起来,IE11缺乏"attachEvent“的支持,而”attachEvent“在jQuery中使用,并且似乎也被框架所使用。有一个微软的错误证明:Bug票证attachEvent IE11。
我在相关jQuery错误票中找到了一个解决方案。只需在框架前插入以下代码:
var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/));
if (isIE11) {
if (typeof window.attachEvent == "undefined" || !window.attachEvent) {
window.attachEvent = window.addEventListener;
}
} 首先检查浏览器是否为IE11,然后再次绑定attachEvent侦听器,这样就不会再次发生错误。
https://stackoverflow.com/questions/19931600
复制相似问题