JavaScript获取屏幕的宽和高(分辨率)

有的时候我们可能需要了解浏览者所使用的显示器分辨率,从而帮助我们网页设计们了解浏览者的一些情况,下面就简单介绍一下利用JavaScript获取屏幕分辨率的方法:

直接在网页里面显示,代码如下:
<script type="text/javascript" language="javascript">
document.write('您显示器的分辨率为:\n' + screen.width + '×' + screen.height + ' 像素');
</script>

在网页弹出显示,代码如下:
<script type="text/javascript" language="javascript">
alert('您显示器的分辨率为:\n' + screen.width + '×' + screen.height + ' 像素')  
</script>  

This entry was posted in Technology and tagged , , . Bookmark the permalink. 6,264 views

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *