我想显示在 iframe 中呈现的 html 文件的源代码。源代码必须以正确的标签颜色和缩进显示,就像在 sublime 等编辑器中一样。 我得到了在 iframe 中呈现的文件的源代码
var sourceCode = '<!DOCTYPE html>\n\<html lang="en-US">\n';
sourceCode += $('#iFrame').contents().find("html").html();
sourceCode += '\n</html>';
sourceCode = sourceCode.replace(/</g, "<").replace(/>/g, ">");
sourceCode = "<pre>"+sourceCode+"</pre>";
最佳答案
在 github 上创建一个要点并嵌入它?
关于javascript - 如何像在编辑器中一样使用适当的标签颜色样式和缩进显示 html 源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41299505/