标签:javascript
1.获取浏览器窗口的有效宽高(不包括工具栏和滚动条)
注:对于绝大部分浏览器使用window.innerWidth即可获取宽度,使用document.documentElement.clientWidth || document.body.clientWidth 为了实现对IE6,7的支持。
高度同上。
var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h=window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; x=document.getElementById("screen_size"); x.innerHTML="浏览器的内部窗口宽度:" + w + ",高度:" + h + "。"
document.write("屏幕可用尺寸,宽:" + screen.availWidth+",高:"+screen.availHeight);3.location相关(获取web服务器相关信息)
document.write("web 主机的域名: "+location.hostname+"<br/>"); document.write("当前页面的路径和文件名: "+location.pathname+"<br/>"); document.write("web 主机的端口: "+location.port+"<br/>"); document.write("所使用的 web 协议: "+location.protocol+"<br/>"); document.write("当前页面的url: "+location.href+"<br/>");
标签:javascript
原文地址:http://blog.csdn.net/books1958/article/details/43667319