您好,欢迎来到爱奥娱乐。
搜索
您的当前位置:首页CodeMirror2IE7/IE8下面未知运行时错误的解决方法_javascript技巧

CodeMirror2IE7/IE8下面未知运行时错误的解决方法_javascript技巧

来源:爱奥娱乐


原来出错的代码如下:
代码如下:





出错的原因应该是IE7、IE8中的P不支持innerHTML。CodeMirror的作者也发现了这个问题,相关链接:
  https://github.com/marijnh/CodeMirror2/issues/215
  https://github.com/marijnh/CodeMirror2/commit/48815d6054571f92fa4d5601ebe7d601e952ab
代码如下:
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,即可正常:
代码如下:



Copyright © 2019- iaaf.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务