I'm trying to get some HTML code from a page. The only way to do this that I know of is

document.getElementById('id').innerHTML = 'newhtml';

But the problem is that the page is taken from the web and it has no IDs to get and I can't modify it by putting IDs.
So is there a way to get the innerHTML of the whole page so I can search for certain strings afterwards?

Hi, SirDorius.

Instead of using


You could use


This method will give you an array of all the elements on the page with that tag name. Just access each tag like you would access an array.

For example, if you wanted to get the inner HTML of the third division on the page you could use:


Hope that helps,


the inner html of the whole html document is

if you just want the bodys html

This question has already been answered. Start a new discussion instead.