你能用javascript获得用户的屏幕尺寸/分辨率吗? [英] Can you get a users screen size/resolution using javascript?
本文介绍了你能用javascript获得用户的屏幕尺寸/分辨率吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用javascript获取用户的屏幕尺寸/分辨率?我认为你可能不能使用PHP这样做,因为它是服务器端,但由于javascript是客户端,我认为它可能是一个选项。
Is there a way to get the a users screen size/resolutions using javascript? I figured you probably can't use PHP to do this as it's server-side, but as javascript is client-side I thought it may be an option.
推荐答案
是的,您可以使用以下内容打印出分辨率,例如:
Yes, you can use the following to print out the resolution for example:
<script type="text/javascript">
document.write(screen.width+'x'+screen.height);
</script>
可能无法在旧版浏览器中使用,但最近的浏览器可能无法使用。
Might not work in older browsers, but will in most recent ones.
此处有更多信息:
http://www.javascriptkit.com/howto/newtech3.shtml
这篇关于你能用javascript获得用户的屏幕尺寸/分辨率吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文