BOM

来源:互联网 发布:贵州轩通大数据怎么样 编辑:程序博客网 时间:2024/06/07 05:24
BOM提供了很多对象来访问浏览器的属性和功能。常用的有window、location、history等;
Window:
window.moveTo(x,y);
window.moveBy(x,y);
window.resizeTo(x,y);
window.resizeBy(x,y);
--------------------以上IE7默认禁用,只对最外层window------------------
var newWin=window.open(url, target,style,replace);
newWin.opener指向打开它的原始窗口;
第二个参数可以是_selft、_parent、_blank、_top;
第三个参数包括:height、width、left、top、resizable;
varpageWidth=windows.innerWidth||window.documentElement.clientWidth||window.body.clientWidth;
setTimeout(fn,t);setInterval(x,y);

confirm(string)返回布尔值
prompt(outString,inString),返回inString或null;
Location:
属性:host、hash、hostname、href、pathname、port、protocol、search
方法:reload()、replace();
修改页面:window.locaton=url、location.href=url一样,都是调用了location.assign(url),或者修改locaton参数也可以定位页面。replace方法不会生成新的历史纪录。reload(true)强行重服务器重新加载。
navigator:
appCodeName
appVersion
appName
...然而最有用的还是userAgent查看浏览器类型