<script>
/**
* 获取显示器的宽高
*/
document.write('返回显示器屏幕的宽度:' + screen.width);
document.write('<br/>返回显示器屏幕的高度:' + screen.height);
document.write('<br/>返回显示器屏幕的宽度(操作系统任务栏除外):' + screen.availWidth);
document.write('<br/>返回显示器屏幕的高度(操作系统任务栏除外):' + screen.availHeight);
/**
* JavaScript实现前进、后退、跳转到指定页面、刷新、查询:协议/主机/端口/资源
*/
// 前进和后退
<a href="javascript:history.back();">后退</a>
<a href="javascript:history.forward();">前进</a>
// 使用js跳转到指定页面
var buttons = document.getElementsByTagName('button');
buttons[0].onclick = function(){
location = 'http://www.jd.com';
}
// F5刷新
buttons[1].onclick = function(){
location.reload();
}
// 协议/主机/端口/资源 (http://www.baidu.com:80/index.html)
document.write('协议:' + location.protocol);
document.write('主机:' + location.hostname);
document.write('端口:' + location.port);
document.write('资源:' + location.pathname);
document.write('完整的URL:' + location.href);
</script>
JavaScript (查询显示器宽高、以及查询:协议/主机/端口/资源)
最新推荐文章于 2024-06-08 06:00:00 发布