JavaScript -- 知识点回顾篇(十):Screen 对象、History 对象、Location 对象

1. Screen 对象

  1.1 Screen 对象的属性

(1) availHeight: 返回屏幕的高度(不包括Windows任务栏)
        (2) availWidth: 返回屏幕的宽度(不包括Windows任务栏)
        (3) colorDepth: 返回目标设备或缓冲器上的调色板的比特深度
        (4) height: 返回屏幕的总高度
        (5) pixelDepth: 返回屏幕的颜色分辨率(每像素的位数)
        (6) width: 返回屏幕的总宽度

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
document.write("可用高度: " + screen.availHeight);
document.write("<br/>可用宽度: " + screen.availWidth);
document.write("<br/>颜色深度: " + screen.colorDepth);
document.write("<br/>总高度: " + screen.height);
document.write("<br/>总宽度: " + screen.width);
document.write("<br/>颜色分辨率: " + screen.pixelDepth);
</script>
</head>
<body>
</body>
</html>

2. History 对象

  2.1 History 对象的属性

   (1) length: 返回历史列表中的网址数

    <!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
document.write("历史列表中URL的数量: " + history.length);
</script>
</head>
<body>
</body>
</html>

  2.2 History 对象的方法

   (1) back(): 加载 history 列表中的前一个 URL
   (2) forward(): 加载 history 列表中的下一个 URL
   (3) go(): 加载 history 列表中的某个具体页面

    <!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
function my_back(){
window.history.back()
}
function my_forward(){
window.history.forward()
}
function my_go(){
window.history.go(-2)
}
</script>
</head>
<body>
<input type="button" value="back()方法" onclick="my_back()">
<input type="button" value="forward()方法" onclick="my_forward()">
<input type="button" value="go()方法" onclick="my_go()">
</body>
</html>

3. Location 对象

  3.1 Location 对象的属性

(1) hash: 返回一个URL的锚部分
        (2) host: 返回一个URL的主机名和端口
        (3) hostname: 返回URL的主机名
        (4) href: 返回完整的URL
        (5) pathname: 返回的URL路径名。
        (6) port: 返回一个URL服务器使用的端口号
        (7) protocol: 返回一个URL协议
        (8) search: 返回一个URL的查询部分

    <!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
document.write(location.hash);
document.write('<br/>'+location.host);
document.write('<br/>'+location.hostname);
document.write('<br/>'+location.href);
document.write('<br/>'+location.pathname);
document.write('<br/>'+location.port);
document.write('<br/>'+location.protocol);
document.write('<br/>'+location.search);
</script>
</head>
<body>
</body>
</html>

  3.2 Location 对象的方法

(1) assign(): 载入一个新的文档
        (2) reload(): 重新载入当前文档
        (3) replace(): 用新的文档替换当前文档

    <!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
function my_assign(){
window.location.assign("https://www.baidu.com")
}
function my_reload(){
location.reload()
}
function my_replace(){
window.location.replace("https://www.hao123.com")
}
</script>
</head>
<body>
<input type="button" value="assign()方法" onclick="my_assign()">
<input type="button" value="reload()方法" onclick="my_reload()">
<input type="button" value="replace()方法" onclick="my_replace()">
</body>
</html>

JavaScript -- 时光流逝(十):Screen 对象、History 对象、Location 对象的更多相关文章

  1. JavaScript -- 时光流逝(十三):DOM -- Console 对象

    JavaScript -- 知识点回顾篇(十三):DOM -- Console 对象 (1) assert() : 如果断言为 false,则在信息到控制台输出错误信息.(2) clear() : 清 ...

  2. JavaScript -- 时光流逝(十一):DOM -- Document 对象

    JavaScript -- 知识点回顾篇(十一):DOM -- Document 对象 (1) document.activeElement: 返回文档中当前获得焦点的元素. <!doctype ...

  3. JavaScript -- 时光流逝(十二):DOM -- Element 对象

    JavaScript -- 知识点回顾篇(十二):DOM -- Element 对象 (1) element.accessKey: 设置或返回accesskey一个元素,使用 Alt + 指定快捷键 ...

  4. JavaScript -- 时光流逝(九):Window 对象、Navigator 对象

    JavaScript -- 知识点回顾篇(九):Window 对象.Navigator 对象 1. Window 对象 1.1 Window 对象的属性 (1) closed: 返回窗口是否已被关闭. ...

  5. JavaScript -- 时光流逝(五):js中的 Date 对象的方法

    JavaScript -- 知识点回顾篇(五):js中的 Date 对象的方法 Date 对象: 用于处理日期和时间. 1. Date对象的方法 <script type="text/ ...

  6. JS浏览器对象:window对象、History、Location对象、Screen对象

    一.JS浏览器对象-window 1.window对象 window对象是BOM的核心,window对象指当前的浏览器窗口 所有JavaScript全局对象.函数以及变量均自动成为window对象的成 ...

  7. JavaScript -- 时光流逝(六):js中的正则表达式 -- RegExp 对象

    JavaScript -- 知识点回顾篇(六):js中的正则表达式 -- RegExp 对象 1. js正则表达式匹配字符之含义      查找以八进制数 规定的字符.     查找以十六进制数 规定 ...

  8. JavaScript -- 时光流逝(四):js中的 Math 对象的属性和方法

    JavaScript -- 知识点回顾篇(四):js中的 Math 对象的属性和方法 1. Math 对象的属性 (1) E :返回算术常量 e,即自然对数的底数(约等于2.718). (2) LN2 ...

  9. JavaScript -- 时光流逝(三):js中的 String 对象的方法

    JavaScript -- 知识点回顾篇(三):js中的 String 对象的方法 (1) anchor(): 创建 HTML 锚. <script type="text/javasc ...

随机推荐

  1. 三大主流软件负载均衡器对比(LVS VS Nginx VS Haproxy)

    LVS:1.抗负载能力强.抗负载能力强.性能高,能达到F5硬件的60%:对内存和cpu资源消耗比较低2.工作在网络4层,通过vrrp协议转发(仅作分发之用),具体的流量由linux内核处理,因此没有流 ...

  2. wget命令的几个常用选项和示例

    wget命令用来从指定的URL下载文件.wget非常稳定,它在带宽很窄的情况下和不稳定网络中有很强的适应性,如果是由于网络的原因下载失败,wget会不断的尝试,直到整个文件下载完毕.如果是服务器打断下 ...

  3. python元组类型

    元组类型简介 使用括号包围的数据结构是元组(tuple).例如: >>> (1,2,3) (1, 2, 3) >>> T = (1,2,3,) >>&g ...

  4. Linux中安装Oracle11g后出现监听的问题及解决办法

    软件安装: 参考文章: linux安装Oracle11G 错误如下: [oracle@iz2f570bi1k56uz admin]$ lsnrctl start LSNRCTL for Linux: ...

  5. svn迁移后本地地址变更及externals无效的问题

    1.软件: visual SVN Server 2.具体方法: 在打开本地原来SVN check  out的根目录,点右键,tortoiseSVN --> relocate 弹出的对话框中修改s ...

  6. Kafka安装与配置(windows)

    作者:灬花儿灬 出处:http://www.cnblogs.com/flower1990/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则 ...

  7. [angularjs] angularjs系列笔记(一)简介

    Angularjs通过新的属性和表达式扩展了html Andularjs 可以构建一个单一页面的应用程序(SPAS SinglePageApplications) Angularjs通过指令扩展了ht ...

  8. 【Linux命令】grep命令

    1.作用 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全 ...

  9. xhr post请求

    1. post提交的时候要设置post请求头,可以使用setRequestHeader(单独指定请求的某个http头) 2.通常在web开发中,使用表单提交数据的时候,一般是使用xml的格式进行的.可 ...

  10. 06-HTML-表格标签

    <html> <head>  <title>表格标签学习</title>  <meta charset="utf-8"/> ...