Home  >  Article  >  Web Front-end  >  CodeMirror2 IE7/IE8 solution to the following unknown runtime error_javascript skills

CodeMirror2 IE7/IE8 solution to the following unknown runtime error_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:54:541647browse

The original error code is as follows:

Copy code The code is as follows:





The reason for the error should be that P in IE7 and IE8 does not support innerHTML. The author of CodeMirror also discovered this problem. Related links:
 https://github.com/marijnh/CodeMirror2/issues/215
 https://github.com/ marijnh/CodeMirror2/commit/4886415d6054571f92fa4d5601ebe7d601e952ab
Copy the code The code is as follows:

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

Throw the textarea outside Change the p of the layer to div and it will work fine:
Copy the code The code is as follows:

< ;div style="margin-top:0;">


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Get the data sent from the server and use JS to remove spaces using regular expressions_javascript skillsNext article:Get the data sent from the server and use JS to remove spaces using regular expressions_javascript skills

Related articles

See more