<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><script type="text/javascript">/******location的属性********/
function testLocation(){// 返回当前网页的url:http://127.0.0.1:8020/jS_learn/012_JS%E4%B8%ADBOM%E5%AF%B9%E8%B1%A11.html?__hbt=1591887366460
var herf = window.location.href;//返回当前网页的服务器ip:127.0.0.1
var hostname = window.location.hostname
// 返回服务器主机:127.0.0.1:8020
var host = window.location.host;// 返回服务器端口:8020
var port = window.location.port
//alert(herf+'----'+hostname+'----'+port+'---'+host)// 重置herf,跳转到重置后的页面
window.location.href='http://www.baidu.com'// 重新加载页面,刷新
//window.location.reload()}/*******history对象******/
function testHistory(){// 当前历史记录的个数属性,返回浏览器列表中url的个数
var lenth = window.history.length
//alert(length)// 前进方法
//window.history.forward()//后退方法
//window.history.back()// 控制前进 或着后退 多个网页,负数代表后退,正数代表前进,为0则刷新当前页面
window.history.go(1)}/*******screen对象*******/
function testScreen(){//获取屏幕的高度
var he =window.screen.height
// 获得屏幕的宽度
var wi = window.screen.width
alert(he+'+++'+wi)}/***********navigator*********/
function testNavigator(){//获得用户代理
var user = window.navigator.userAgent
alert(user)}</script></head><body><p><inputtype="button" name=""id="" value="location对象" onclick="testLocation()"/></p><p><inputtype="button" name=""id="" value="history对象" onclick="testHistory()"/></p><p><inputtype="button" name=""id="" value="screen对象" onclick="testScreen()"/></p><p><inputtype="button" name=""id="" value="Navigator对象" onclick="testNavigator()"/></p></body></html><!--location history nav 等对象的学习是从属性和方法两方门面来学习-->