window.open()会返回一个指向新窗口的引用,可使用resizeTo()、moveTo()、close()方法,对新打开的窗口进行操作;弹出的窗口关闭后,closed属性可检测窗口是否关闭
opener设置为null断开与父页面的通信,默认值为对父页面的引用,断开通信后在单独的进程中运行
弹出窗口屏蔽程序:
var blocked = false;
try{
var wroxWin = window.open("http://www.wrox.com","_blank");
if(wroxWin == null){
blocked = true;
}
}catch(err){
blocked = true;
}
if(blocked){
alert("the Popup was blocked!");
}
浏览器默认拦截窗口时window.open()返回null,其他插件程序会报错
延时调用实现间歇调用:
var num = 0;
var max = 10;
function incrementNumber(){
num++;
if(num < max){
setTimeOut(increment,500);
}else{
alert("done");
}
}
setTimeOut(increment,500);
window.print() //打印,window.find() //查找 ,window系统对话框调用
location既是window的属性,也是document的属性,window.location == document.location //true location对象拥有很多属性,search 查询字符串被编码过,用decodeURLComponent()列具体的属性和值
function getQueryStringArgs(){
var qs = (location.search.length > 0 ? location.search.substring(1) : "");
var args = {};
var items = qs.length ? qs.split("&") : [],
var item = null,name = null,value = null;
if(var i = 0; i < items.length; i++){
item = items[i].split("=");
name = decodeURLComponent(item[0]);
value = decodeURLComponent(item[1]);
if(name.length){
args[name] = value;
}
}
return args;
}
网友评论