<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<script language="JavaScript">
<!--
function displayTags()
{
var tag, tags;
tags = "Here are the tags in the page:"
for(i = 0; i < document.all.length; i++)
{
tag = document.all(i).tagName;
tags = tags + "<br>" + tag;
}
document.write(tags);
}
// -->
</script>
</head>
<body onload="displayTags()">
<h1>My <b>Website</b></h1>
</body>
</html>
output:
Here are the tags within this webpage:
HTML
HEAD
META
BODY
H1
B
If I uncomment the first document.write() line, the output changes to:
The tags on this page are:
HTML
HEAD
BODY
It seems that some tags are missing. Where could the mistake be? Thank you in advance.