\r\n', autoCloseTags: true, }); function viewPage() { html = ""; html = $(".CodeMirror-code").text(); alert(html); view = window.open("", "view") view.document.open() view.document.write(html) // value of text area view.document.write("
") // solves a bug view.document.close() } r.onclick = function() { var n = $(".CodeMirror-code").find("pre").text(); // if (n != e) { var r = window.open("", "", ""); r.opener = null, r.document.write(n), r.document.close() //} else alert("請將需要運行的HTML填寫到輸入框后再運行!", "alert", "運行提示") } console.log($(".CodeMirror-code").find("pre").text());