window location history navigator

A: window是浏览器的一个实例
1,即是JS访问浏览器的一个接口。
2,又是ECMAScript的全局对象(global对象)
B: location对象包含有关当前URL的信息
C: navigator对象包含有关浏览器的信息
D: history对象包含用户在浏览器中访问过的URL
E: screen对象包含有关客户端显示屏幕的信息
**window **
BOM是Browser Object Model的缩写,是浏览器对象模型,核心是window对象,所有的全局变量和全局函数都被归在了window上,所以我们平常定义的变量都属于window。
window.alert():显示带有一段消息和一个确认按钮的警告框。
window.prompt()弹出输入框。
window.confirm():显示一个带有消息和‘确认’及‘取消’按钮的对话框,返回值为boolean类型。
window.open/close():打开新窗口或者关闭浏览器窗口。
setTimeout()方法用于指定的时间后执行一次代码:
var timer=setTimeout(fn,time) clearTimeout(timer)清除超时调用
setInterval()方法用于指定的时间后执行一次代码
var timer=setInterval(fn,time) clearInterval(timer)清除间歇调用
间歇调用与超时调用类似,只不过它会按照指定的时间间隔重复执行代码,直至间歇调用被取消或页面被卸载。设置间歇调用的方法是setInterval(),它接收的参数与setTimeout()相同。取消间歇调用的重要性远高于超时调用。
location
采用示例:当前页面的地址信息
location.href = "index.html#name?age=10&num=20";

location.hash: 设置或返回从井号 (#) 开始的 URL(锚)。//name
location.href: 设置或返回完整的 URL。//index.html#top?age=10&num=20
location.port: 设置或返回当前 URL 的端口号。//8080
location.protocol: 设置或返回当前 URL 的协议。//http
location.search: 设置或返回从问号 (?) 开始的 URL(查询部分)。//age=10&num=20
location.host:返回服务器名称和端口号。//
location.hostname:返回不带端口号的服务器名称。
location.pathname:返回url中的目录和文件名。
history
history.forward():回到历史记录的下一步,相当于history.go(1);
history.back()与在浏览器中点击按钮向前相同;
history.go()跳转到上一个页面相当于 history.go(-1);
navigator
navigator.userAgent; 用户代理。

if(navigator.userAgent.indexOf("Android") > -1){
console.log("安卓")
}else
if(navigator.userAgent.indexOf("iPhone") > -1){
console.log("苹果")
}else{
console.log("PC")
}

navigator.appVersion; 返回浏览器的平台和版本信息。
screen
screen.width; //客户端屏幕的宽度,px。
screen.height; //客户端屏幕的高度,px。
screen.availWidth 属性返回可用屏幕的宽度,px。
screen.availHeight 属性返回可用屏幕的高度,px。

window location history navigator

上一篇:使用Duilib开发Windows软件(7)——control 类


下一篇:Windows常用快捷键