網(wǎng)頁內(nèi)容的高度和寬度,“內(nèi)容”二字怎么理解??
這個(gè)是輸出結(jié)果:
669*8
669*34
669*958
以下是代碼:
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">? </head> <body> <script?type="text/javascript"> var?w=document.documentElement.scrollWidth||?document.body.scrollWidth; var?h=document.documentElement.scrollHeight||?document.body.scrollHeight; document.write(w+"*"+h+"<br>"); var?w=document.documentElement.scrollWidth var?h=document.documentElement.scrollHeight document.write(w+"*"+h+"<br>"); var?w=document.body.scrollWidth; var?h=document.body.scrollHeight; document.write(w+"*"+h+"<br>"); </script> </body>???? </html>
2015-12-09
我的理解。
1、document.documentElement.scrollHeight||?document.body.scrollHeight;是判斷語句。如果第一個(gè)有值就取第一個(gè)值。
2、為什么第二次是34,那是因?yàn)樵谳敵龅诙械臅r(shí)候文本高度就是在34左右(有2個(gè)像素誤差)。
3、document.body.scrollHeight這個(gè)值是直接輸出的整個(gè)瀏覽器高度
2015-08-18
至于為什么是8....因?yàn)槟J(rèn)了...你可以打開f12查看
2015-08-18
首先在獲取內(nèi)容之前,你輸出的語句的第一個(gè)值就是8,之后再輸出語句時(shí),因?yàn)橛辛藘?nèi)容了,所以會(huì)輸出34,高度被改變了
2015-08-14
就拿你這里的例子,內(nèi)容就是body里的東西