Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I want to display all HTML sou 1

Status
Not open for further replies.

Adhie

Programmer
Mar 17, 2003
28
SG
Hi,
I want to display all HTML source using javascript, in it's page it self.
Problem:
<html><title>Source Code</title>
<body><script LANGUAGE=&quot;JavaScript&quot;>
alert(document.body.innerHTML )
</script></body></html>
----------------------------
It only will show :
<script LANGUAGE=&quot;JavaScript&quot;>
alert(document.body.innerHTML )
</script>
----------------------------

I want it show from <html> till </html>.
This is for HTML web based editor that I still developing.
Any idea, please?

Thanks
 
It's only doing what you've asked it to do. document.body.innerHTML will return all the HTML enclosed by the <body></body> tags.

If you want to return the HTML for the full document, use document.documentElement.innerHTML
 
Aye, we're a misunderstood lot. But we refuse to surrender to outdated moral concepts like political correctness.

Thanks, I needed a laugh... was up all night attending to a sick 14-month-old, and in the absence of sleep, a laugh is much needed medicine :)
 
dwarfthrower,

pretty cool - i've never used the documentElement object before.

you can also use
document.getElementsByTagName(&quot;html&quot;)[0].innerHTML;

=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Thanks you guys, special for dwarfthrower, your answer quite right.

Anyway I got another problem on my web based content editor (WBCE).
My WBCE should be able to perform ASP programming. Any idea? please drop me a sample.

Thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top