如何用 js 取得浏览器的高度并赋值给div?

2024-12-28 04:33:17
推荐回答(1个)
回答1:

js 取得浏览器的高度并赋值给div的步骤如下:

1. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> </p> <p>2.请调整浏览器窗口大小</h2><hr /><form action="#" method="get" name="form1" id="form1"><!--</p> <p>3.显示浏览器窗口的实际尺寸-->浏览器窗口 的 实际高        度: <input type="text" name="availHeight" size="4"/><br /></p> <p>4.浏览器窗口 的 实际宽度: <input type="text" name="availWidth" size="4"/><br /></form><script type="text/javascript"><!-- var winWidth = 0;var winHeight = 0;function findDimensions() </p> <p>5.//函数:获取尺寸{//获取窗口宽度if (window.innerWidth)winWidth = window.innerWidth;else if ((document.body) && (document.body.clientWidth))winWidth = document.body.clientWidth;//获取窗口高度document.form1.availHeight.value= winHeight;document.form1.availWidth.value= winWidth;}findDimensions();//调用函数,获取数值window.onresize=findDimensions;//--></script></body></html></p> </p> </div> </div> <div class="clear"></div> </div> </div> </div> <div class="wendaright"> <div class="wdluluerwema"> <div class="wdxgwttop">相关问答</div> <div class="wdxgwtnr"> </div> <div class="clear"></div> </div> <!-- 其他随机问答['id'=>alphaID($like['zid'])] --> <div class="wdluluerwema"> <div class="wdxgwttop">最新问答</div> <div class="wdxgwtnr"> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/87141390.html">什么西装适合年轻人而且价格不贵</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/616458108262121292.html">如何修改access数据库用户登录验证的用户名和密码?已知用户名和密码。</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1049773309640428019.html">一辆车让运输公司做了两次分期我该怎么办,车辆被收回了!</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/436326663143348324.html">2016年10月10至15号黄龙演唱会</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/584743353.html">从重庆到乐山坐汽车要多久,价格多少,每天有几班车?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/327480790682200325.html">股票解禁之后对股票的走势会有什么影响?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/54255188.html">谁能告诉我商场保洁的合同范本,谢谢了,</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/37103257.html">衣服有色差,用来修色的药水叫什么?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/256713910.html">哪位高人有宫崎骏的《借东西的小人阿莉埃蒂》视频影片</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/579301497.html">对库存现金进行盘点时必须做到()</a></div> </div> </div> </div> </div> <div class="clear"></div> <div class="footer"> <!-- 移动底部导航 --> <div class="fanhuitop"><a href="#top" ref="nofollow"><img src="https://www.51a.net/static/old/img/fhtop.png" alt="返回顶部" title="返回顶部"></a></div> <div class="dibu"> <div class="dibu"> </div> </div> <div class="banquan"> <p>内容全部来源于网络收集,如有侵权,请联系网站删除:QQ:24596024</p> </div> </div> </div> </div> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?aa60e2f779ee696abd6a207eac06903d"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>