1.history
go(-1)前一页 go(1)后一页 go(2)后两页
back()前一页 forward后一页
history.length历史记录数 可以用history.length=0判断是否当前页面是不是用户历史记录中的第一个页面
eg:
history.go(-1);
history.go("wrox.com");
history.forward();
if (history.length == 0){
//这应该是用户打开窗口后的第一个页面
}
2.navigator
检测是否安装某一插件
eg:
//检测所有浏览器中的 Flash
function hasFlash(){
var result = hasPlugin("Flash");
if (!result){
result = hasIEPlugin("ShockwaveFlash.ShockwaveFlash");
}
return result;
}
//检测插件(在 IE 中无效)
function hasPlugin(name){
name = name.toLowerCase();
for (var i=0; i < navigator.plugins.length; i++){
if (navigator. plugins [i].name.toLowerCase().indexOf(name) > -1){
return true;
}
}
return false;
}
//检测 IE 中的插件
function hasIEPlugin(name){
try {
new ActiveXObject(name);
return true;
} catch (ex){
return false;
}
}