采用alert()、confirm()、prompt()方法可以调用系统对话框向用户展示消息
confirm()对话框会有OK和Cancel两个按钮,OK返回true,Cancel返回false
prompt()会生成一个提示框,提示用户输入文本,有OK和Cancel,选择OK返回输入内容,选择其他的返回Null
location对象用来返回当前窗口中加载文档的有关信息,
function getQueryStringArgs(){
var qs = (location.search.length > 0 ? location.search.substring(1) : "");
args = {};
items = qs.length ? qs.split("&") : [];
item = null;
value = null;
name = null;
i = 0;
len = item.length;
for (i = 0; i < len; i++) {
item = items[i].split("=");
name = decodeURIComponent(item[0]);
value = decodeURIComponent(item[1]);
if (name.length) {
args[name] = value;
}
}
return args;
}
使用location对象的位置操作可以改变浏览器的位置
location.href = “URL” //立即打开新URL
调用location的replace方法,不会产生历史纪录,无法后退
navigator方法
可通过遍历navigator的plugins数组来检测插件
但在IE中无效
history对象用来前进和后退
history.go(1);
history.go(-1);
history.go(2);
也可以传给这个函数一个字符串参数,会跳转到包含该字符串的第一个位置,可能前进也可能后退
history.back();
history.forward();
也可实现前进与后退