开发者

Show and style HTML source code in HTML page

开发者 https://www.devze.com 2023-04-11 19:15 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消