Show and style HTML source code in HTML page
I would like to display HTML source code in an HTML page. So I want it to look like it loo开发者_开发百科ks in your text editor. The source will be the complete source code, from the <html>
tag to the end. So it needs to include the <head>
and <body>
with all styles in the <head>
.
How would I do this?
<textarea name="Source Code"></textarea>
then set the value of that text area to
document.getElementsByTagName('html')[0].innerHTML
You might need to add the html tags again. But that should be no problem
Edit 2018
Someone upvoted this. I would highly recommend you take a look at https://highlightjs.org/. Its a very good solution for the stated problem.
精彩评论