/    Sign up×
Community /Pin to ProfileBookmark

Getting the document’s innerHTML

Hi,
Do you know how to get the document’s innerHTML? This is no good:
[COLOR=red]document.body.innerHTML[/COLOR]
as it only get the body’s innerHTML

Please help ?

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@neewahauthorAug 24.2004 — Sorry

I've just worked it out:

document.all[0].innerHTML

? ? ? ?

[i]typo...[/i]
Copy linkTweet thisAlerts:
@TheBearMayAug 24.2004 — document.documentElement.innerHTML should give you everthing after the <HTML> tag...
Copy linkTweet thisAlerts:
@TheBearMayAug 24.2004 — [i]Originally posted by neewah [/i]

[B]Sorry

I've just worked it out:



document.all[0].innerHTML



? ? ? ?



[i]typo...[/i] [/B]
[/QUOTE]


...not in FireFox.
Copy linkTweet thisAlerts:
@BillyRayAug 24.2004 — Only that's not strictly true - try adding a comment as the first line of your file and seeing what happens.

AFAIK, there is no foolproof way of doing what you are asking in 1 single call, and certainly not that would work across different browsers and operating systems.

Dan
Copy linkTweet thisAlerts:
@CharlesAug 24.2004 — [i]Originally posted by TheBearMay [/i]

[B]document.documentElement.innerHTML should give you everthing after the <HTML> tag... [/B][/QUOTE]
[font=monospace]document.documentElement.outerHTML[/font] shouldn't give you everything but the prolog, but it does. "Element.outerHTML", like "Element.innerHTML" is a Microsoft corruption of JavaScript that is as useful as it is destructive to the whole idea of the DOM.
Copy linkTweet thisAlerts:
@neewahauthorAug 24.2004 — Wow ?

So many ideas....

Which one should I use???

--

http://www.neewah.com
--

Copy linkTweet thisAlerts:
@BillyRayAug 24.2004 — Which one should I use???[/quote]

Maybe if you told us [b]why[/b] you want to do this, we could suggest a better / more compliant method?

Dan
Copy linkTweet thisAlerts:
@neewahauthorJul 12.2005 — I was going to make a HTML editor using javascript and PHP, and I might need to get the page's HTML once PHP has written in its code.

Also, it must have been about a year ago once I posted this topic, i have learnt a lot more in that time, especially with server-side language PHP, and also using JavaScript to give really good effects

Anyway, thanks for your help ?

--

Phew, its boiling here in England ?

--
×

Success!

Help @neewah spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...