/    Sign up×
Community /Pin to ProfileBookmark

Javascript+DOM

Hello,

I would like to show with DOM the contents of a HTML’s page. Does somebody know if it is possible and if so, how I can do this?

Thank you very much

***Sorry for my english***

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 22.2004 — <body onload="alert(document.body.innerHTML);">
Copy linkTweet thisAlerts:
@CedricauthorJan 22.2004 — Ok, thank you very much.

But there is not a possibility by using "getElementByTagName()" or other? Because, which I would like to do, it is to recover all the objects (<p>, <img>, <a>,...) which have an attribute "class" and with "document.body.innerHTML" I do not know how to do that.

Thank you.
Copy linkTweet thisAlerts:
@FangJan 22.2004 — This would find all the <p class="heading"> elements within the element with id="object_id"
var oRoot=document.getElementById('object_id');
var oList=oRoot.document.getElementsByName('p');
for(var i=0; i&lt;oList.length; i++) {
if(oList[i].getAttribute('class')=="heading") {
// do something here
}
}
Copy linkTweet thisAlerts:
@CedricauthorJan 23.2004 — Hello, thank you very much for your help fang.

Ok, I will make like this , and I also found a means to show all the objects of the page, I use "getElementsByTagName("*")" and it goes well.

Thank you still.

Cédric
×

Success!

Help @Cedric 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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