PDA

View Full Version : How to get content/source of html page using DOM


kokilakr
06-01-2010, 05:33 AM
Hello,

Can you please inform me how to get the complete content/source of webpage maintaining current state using javascript/standard DOM interface?

Thanks,

Dormilich
06-01-2010, 07:27 AM
please specify "how to get content". do you mean fetch the content from somewhere or print out the current document?

kokilakr
06-01-2010, 07:54 AM
Hello,

please specify "how to get content". do you mean fetch the content from somewhere or print out the current document?

I need to save webpage source to another .html file. Yes it is same as, print out current document. I am able to retrieve the source using document.childNodes[i].outerHTML;. But The outerHTML is not part of standard DOM interface and the entities are not displayed properly. So I need a better approach to get the content of html file where entities like &nbsp and & are skipped and current state of document is maintained.

Even the document.getElementsByTagName('html')[0].innerHTML; does not work.

Thanks