/    Sign up×
Community /Pin to ProfileBookmark

I need a refresher.

Okay so I’ve just restarted a personal project I was doing about two months ago. I completely forget how to write things on the screen using javascript (sad, I know.) So what I’m doing is access a table and trying to print out the contents. Here’s my code:

[CODE]function DisplayGuts(){ //The purpose of this fucntion is to display the inner HTML of page.
var page = document.body.getElementsByTagName(‘td’);
for (var n = 0; n < document.body.getElementsByTagName(‘td’).length; n++){
window.document.write(page[n].innerHTML);
}
}[/CODE]

What I am doing wrong?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 02.2008 — [I]document.write[/I] will write a new document, the original document then no longer exists.

'Write' to a specific location; a div or textarea for example.
document.getElementById('contents').innerHTML+=page[n].innerHTML;
×

Success!

Help @Lawrence_Fields 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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