js浏览器对象

history 对象 

 窗口被打开的那一刻开始记录,每个浏览器窗口、每个标签页乃至每个框架,都有自己的history对象与特定的window对象关联。

语法:

window.history.[属性|方法]

  属性: length 返回浏览器历史中的URL数量。

  方法:back() 加载history列表的前一个URL  go(-1)

          forward() 加载history列表的下一个URL  go(1)

          go()    加载history列表中的某一个具体的页面。

Location 对象 用于获取或设置窗体的URL,并可以用于解析URL。

属性:

hash 设置或返回从#开始的URL(锚)

host 设置或返回主机名  和  当前URL的端口号。

hostname 设置或返回当前URL的主机名。

port   设置返回当前URL的端口号。

herf   返回完整的URL。

pathname 设置或返回当前URL的路径部分。

protocol   设置或返回当前URL的协议。

search   设置或返回从?开始的URL查询部分。

location对象方法:

assign()  加载新的文件

reload() 重新加载当前文件

replace()  用新的文件替换当前文件。

Navigator对象 包含有关浏览器的信息,通常用于检测浏览器与操作系统的版本。

appCodeName  浏览器代码的字符串表示。

appName     返回浏览器的名称。

appVersion  返回浏览器的版本信息。

platform      返回浏览器的操作系统平台。

userAgent   返回客户机发送服务器的 user-agent 头部的值。返回用户代理头的字符串表示(包括浏览器版本信息等的字符串)

eg:使用userAgent判断使用的是什么浏览器?

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>navigator</title>
<script type="text/javascript">
  function validB(){ 
      alert("hello");
    var u_agent =   navigator.userAgent    ; 
    var B_name="不是想用的主流浏览器!"; 
    if(u_agent.indexOf("Firefox")>-1){ 
        B_name="Firefox"; 
    }else if(u_agent.indexOf("Chrome")>-1){ 
        B_name="Chrome"; 
    }else if(u_agent.indexOf("MSIE")>-1&&u_agent.indexOf("Trident")>-1){ 
        B_name="IE(8-10)";  
    }
        document.write("浏览器:"+B_name+"<br>");
        document.write("u_agent:"+u_agent+"<br>"); 
  } 
</script>
</head>
<body>
  <form>
     <input type="button" value="查看浏览器"  onclick="validB()"  >
  </form>
</body>
</html>

screen对象,用于获取用户的屏幕信息。

window.screen.属性

oracle Form 开发
原文地址:https://www.cnblogs.com/watson945/p/5089345.html