我是靠谱客的博主 彪壮皮带,最近开发中收集的这篇文章主要介绍CodeMirror2 IE7/IE8 下面未知运行时错误的解决方法,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

原来出错的代码如下:

复制代码 代码如下:

<p style="margin-top:0;">
<asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Height="450" Width="98%"></asp:TextBox>
</p>

出错的原因应该是IE7、IE8中的P不支持innerHTML。CodeMirror的作者也发现了这个问题,相关链接:
  https://github.com/marijnh/CodeMirror2/issues/215
  https://github.com/marijnh/CodeMirror2/commit/4886415d6054571f92fa4d5601ebe7d601e952ab
复制代码 代码如下:

try { stringWidth("x"); }
catch (e) {
if (e.message.match(/runtime/i) || e.message.match(/运行时/i) )
e = new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)");
throw e;
}

把textarea外层的p改成div,即可正常:
复制代码 代码如下:

<div style="margin-top:0;">
<asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Height="450" Width="98%"></asp:TextBox>
</div>

最后

以上就是彪壮皮带为你收集整理的CodeMirror2 IE7/IE8 下面未知运行时错误的解决方法的全部内容,希望文章能够帮你解决CodeMirror2 IE7/IE8 下面未知运行时错误的解决方法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(118)

评论列表共有 0 条评论

立即
投稿
返回
顶部