Title
My Web Page
output:
The tags in the page are:
HTML
HEAD
META
TITLE
SCRIPT
BODY
H1
B
By un-commenting the first document.write() I get the following output:
8The tags in the page are:
HTML
HEAD
BODY
Some tags are missing, I don't understand where the mistake is! I thank you in advance.
Answer
This is because document.write being called after the document is done loading, it erases and replaces the current document. If you see here: onload="showtags()" that's why it's happening. document.write needs to be called BEFORE the DOM is done loading. For example:
Is ok, because the DOM is still loading. But in a onload, or after the page is done loading in general , is not.
No comments:
Post a Comment