I wrote some HTML code to use CodeMirror to highlight code in my textarea. I wanna do this for javascript, but I don't understand why there are no text highlights in my textarea.
<html>
<head>
<script src="js/codemirror.js"></script>
<link rel="stylesheet" href="codemirror-4.7/lib/codemirror.css">
<link rel="stylesheet" href="css/docs.css">
<script src="codemirror-4.7/mode/javascript/javascript.js"></script>
<title>TestHTML</title>
</head>
<body>
<textarea id="code">
</textarea>
<script type="text/javascript">
var myCodeMirror = CodeMirror(document.getElementById("code"), {
mode:"javascript",
lineNumbers: true
});
</script>
</body>
</html>
This is my code. So maybe you can find my mistake :)
Edit:
The error code is:
GET file://themes.googleusercontent.com/static/fonts/sourcesanspro/v5/ODelI1aHBYDBqgeIAH2zlBM0YzuT7MdOe03otPbuUS0.woff net::ERR_FILE_NOT_FOUND
The way you're invoking the CodeMirror constructor tells it to append itself to a textarea -- which is a kind of element that can't have children. You probably want to call CodeMirror.fromTextArea
instead of plain CodeMirror
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.