ã¯ããã«
ãWebãã©ã¦ã¶ï¼ä»¥ä¸ããã©ã¦ã¶ï¼ã®ç¨®é¡ããã¼ã¸ã§ã³ãåã ã®ãã©ã¦ã¶ç¬èªã®å®è£ ã®éããèæ ®ããåãããã«åä½ããã¹ã¯ãªããããã¯ãã¹ãã©ã¦ã¶ã¹ã¯ãªãããã¨è¨ãã¾ããããã§ã¯ãã¯ãã¹ãã©ã¦ã¶ã¹ã¯ãªãããå®ç¾ããæ¹æ³ã«ã¤ãã¦ãé ã追ã£ã¦è§£èª¬ãã¦ãã¦ãã¾ãã
ãæ¬æ¥ã®JavaScriptã®çæ³çãªå§¿ã¨ãã¦ãä¸ã¤ã®ã¹ã¯ãªãããæ¸ãã°ãJavaScriptããµãã¼ããããã©ã¦ã¶ã§ããã°ãåãããã«åãã¹ããªã®ã§ãããããããããã©ã¦ã¶ã«ãã£ã¦ç´°ããªå®è£ ã®éãããããããã¯ãã¹ãã©ã¦ã¶ã¹ã¯ãªããã®ãã¯ããã¯ãå¿ è¦ã¨ãªã£ã¦ãã¾ãã
ãç¾å¨ä¸è¬çã«ä½¿ããã¦ãããã©ã¦ã¶ã§ãããInternet ExplorerãFirefoxãOperaãSafariãªã©ã§ã¯ããããã®ãã©ã¦ã¶ã®ç©æ¥µçãªDOMãµãã¼ãã®ãããã§ã以åã»ã©å¤ãã®å®è£
ã®éãã¯ãªããªã£ã¦ãã¦ãã¾ãããããããã§ããJavaScriptã®ä¸ã§ãæ¯è¼çãã使ããã¦ããevent
ãªãã¸ã§ã¯ãã¨window
ãªãã¸ã§ã¯ãã«ã¯ãå¤ãã®å®è£
ã®éããåå¨ãã¾ãã
ããã®ä¸ã§ååã¯ãevent
ãªãã¸ã§ã¯ãã®ãã©ã¦ã¶ã«ããå®è£
ã®éãã«ã¤ãã¦è§£èª¬ãã¾ãããä»åã¯ãæ®ãã®window
ãªãã¸ã§ã¯ãã®å®è£
ã®éãã«ã¤ãã¦è§£èª¬ãã¦ããããã¨æãã¾ãã
ã³ã³ãã³ã表示é åã®åå¾æ¹æ³
ãJavaScript1.2ã§ã¯ãã¦ã¤ã³ãã¦ã®å¤å¨ãã¦ã¤ã³ãã¦ã®å å¨ãã¤ã¾ãã¦ã¤ã³ãã¦å ã®ã³ã³ãã³ã表示é åã®ãµã¤ãºã®å¤ãåå¾ããã次ã®ãããªããããã£ã追å ããã¾ããã
innerHeight //ã¦ã£ã³ãã¦å å¨(ã³ã³ãã³ã表示é å)ã®é«ã innerWidth //ã¦ã£ã³ãã¦å å¨(ã³ã³ãã³ã表示é å)ã®æ¨ªå¹ outerHeight //ã¦ã£ã³ãã¦å¤å¨ã®é«ã outerHeight //ã¦ã£ã³ãã¦å¤å¨ã®æ¨ªå¹
ããããã®ããããã£ã¯ãJavaScript1.2ã«å¯¾å¿ãããã©ã¦ã¶ã®ä¸ã§ããNetscape Navigator4.X以éã®NetscapeãFirefoxãå§ãã¨ããMozillaç³»ãã©ã¦ã¶ãOperaãSafariã§ã¯å¯¾å¿ãã¦ãã¾ãããInternet Explorerã§ã¯å¯¾å¿ãã¦ãã¾ãããããããã³ã³ãã³ã表示é åã®ãµã¤ãºã®å¤ã«é¢ãã¦ã¯ãInternet Explorerã§ã次ã®ç¨æ³ã使ãã°åå¾ãããã¨ãã§ãã¾ãã
document.bodyè¦ç´ .clientHeight //ã¯ã©ã¤ã¢ã³ãã®é«ã document.bodyè¦ç´ .clientWidth //ã¯ã©ã¤ã¢ã³ãã®æ¨ªå¹
ãclientHeight
ãclientWidth
ã¯DOMå±æ§ã§ãããã®ãã¡clientHeight
ã¯è¨å®ããHTMLã¿ã°è¦ç´ ã®é«ãã®å¤ããclientWidth
ã¯è¨å®ããHTMLã¿ã°è¦ç´ ã®æ¨ªå¹
ã®å¤ãããããæã£ã¦ãã¾ããInternet Explorer4.X以éã®Internet ExplorerããFirefoxãå§ãã¨ããNetscape6以éã®Mozillaç³»ãã©ã¦ã¶ãOperaãSafariã¯ããã©ã¦ã¶èªèº«ãDOMåããã¦ãã¾ãããã®ãããããã®ãã©ã¦ã¶ã§ã¯ãclientHeight
å±æ§ãclientWidth
å±æ§ãããJavaScriptã使ã£ã¦å¤ãåå¾ãããã¨ãã§ãã¾ããã¤ã¾ããbody
è¦ç´ ããJavaScriptã使ã£ã¦clientHeight
å±æ§ãclientWidth
å±æ§ã®å¤ãåå¾ãããã¨ã«ãããinnerHeight
ããããã£ãinnerWidth
ããããã£ã¨åããã³ã³ãã³ã表示é åã®é«ãã¨æ¨ªå¹
ã®å¤ãåå¾ã§ããã®ã§ãã
ã次ã®ãµã³ãã«ã¯ãJavaScriptã®innerHeight
ããããã£ãinnerWidth
ããããã£ã¨DOMã®body
è¦ç´ ã®clientHeight
å±æ§ãclientWidth
å±æ§ã®å¤ãããããåå¾ããæ¸ãåºãã¦ãã¾ãã
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> <meta http-equiv="Content-Script-Type" content="text/javascript"> <meta http-equiv="Content-Style-Type" content="text/css"> <title>Sample_1</title> <style type="text/css"> <!-- body { background-color: #ffffff; } --> </style> </head> <body> *ã³ã³ãã³ã表示é åã®é«ããæ¨ªå¹ <p> <script type="text/javascript"> <!-- document.write("ã³ã³ãã³ã表示é åã®é«ã(innerHeight)ï¼"); document.write(window.innerHeight); document.write("<br>"); document.write("ã³ã³ãã³ã表示é åã®æ¨ªå¹ (innerWidth)ï¼"); document.write(window.innerWidth); //--> </script> </p> <p> <script type="text/javascript"> <!-- document.write("bodyè¦ç´ ã®é«ã(clientHeight)ï¼"); document.write(document.body.clientHeight); document.write("<br>"); document.write("bodyè¦ç´ ã®æ¨ªå¹ (clientWidth)ï¼"); document.write(document.body.clientWidth); //--> </script> </p> </body></html>
ããµã³ãã«ã®å®è¡çµæãè¦ã¦ã¿ãã¨ãinnerHeight
ããããã£ã¨clientHeight
å±æ§ãinnerWidth
ããããã£ã¨clientWidth
å±æ§ããããããåãå¤ã«ãªã£ã¦ãããã¨ãåããã¨æãã¾ãã