asp.net mvc - MicrosoftMvcAjax.js 在 IE8 中更新表元素时抛出 javascript 错误

发布于 2024-09-11 05:21:09 字数 154 浏览 3 评论 0原文

在 IE8 或更早的版本中,某些元素(例如 TR 和 HTML)不支持innerHTML。 TD。不幸的是,MVC 2 项目中包含的 MicrosoftMvcAjax.js 文件使用innerHTML 作为Ajax.BeginForm 或Ajax.ActionLink 中的Ajax 更新方法。

In IE8 or anything older, innerHTML is not supported on certain elements like TR & TD. Unfortunately, the MicrosoftMvcAjax.js file included in the MVC 2 project uses innerHTML for the Ajax update method within the Ajax.BeginForm or Ajax.ActionLink.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

书信已泛黄 2024-09-18 05:21:26

要解决这个问题,请查看 MicrosoftMvcAjax.js 的第 18 行并将其替换为:

Sys.Mvc.MvcHelpers.updateDomElement=function(target,insertionMode,content){if(target){switch(insertionMode){case 0:$(target).html(content);break;case 1:if(content&&content.length>0){$(target).html(content+target.innerHTML.trimStart());}break;case 2:if(content&&content.length>0){$(target).html(target.innerHTML.trimEnd()+content);}break;}}}

基本上,我取出了 innerHTML 调用并将其替换为 jQuery 的 html()。

To fix that, look into Line 18 of MicrosoftMvcAjax.js and replaced it with this:

Sys.Mvc.MvcHelpers.updateDomElement=function(target,insertionMode,content){if(target){switch(insertionMode){case 0:$(target).html(content);break;case 1:if(content&&content.length>0){$(target).html(content+target.innerHTML.trimStart());}break;case 2:if(content&&content.length>0){$(target).html(target.innerHTML.trimEnd()+content);}break;}}}

Basically, I took out the innerHTML call and replaced it with jQuery's html().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文