Http://bbs.zhinengshe.com/thread-1199-1-1.html
1. Do you add a click event on a blank page to the body?
1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <title></title>6 <Script>7 window.onload= function () {8 Document.body.onclick= function () {9 Alert ("Hello");Ten } One } A </Script> - </Head> - <Body> the </Body> - </HTML>
2. What is document?
1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <title></title>6 <Script>7 window.onload= function () {8 Alert (document.childnodes[1].tagname);9 }Ten </Script> One </Head> A <Body> - </Body> - </HTML>
The popup result is "HTML". The topmost node in the code is <! DOCTYPE html> and
3. Add the Click event to the document, and things will be all right.
1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <title></title>6 <Script>7 window.onload= function () {8 Document.onclick= function () {9 Alert ("Hello");Ten } One } A </Script> - </Head> - <Body> the </Body> - </HTML>
The stem of body and document