标签:
浏览器对象模型——BOM(没有标准样式,有兼容问题,所以少用)
A.window对象
A-1:窗口操作
IE:
moveBy(dx,dy)
移动的距离,相对移动
moveTo(x,y)
移动位置,绝对移动
resizeBy(dw,dh)
resizeTo(w,h)
window.screenLeft
window.screenTop
document.body.offsetWidth
document.body.offsetHeight
Mozilla提供的:
window.scrennX/Y判断窗口位置
window.innerWidth/Heigth判断视口大小
window.outerWidth/Height判断浏览器窗口自身的大小
A-2:新打开的窗口
window.open("URL","Name","属性等")
window.open("page2.html"," ","width=400px,heigth=400px");
window.close();
A-3:系统对话框
alert( )只接受一个参数
alert("afja");字符串加" "
alert(123);
confirm( )有返回值true/false,能做判断
if(confirm("是否提交")) {
alert("提交成功!");
} else {alert("提交失败!");}
prompt("提示文字","输入的值")
var str = window.prompt("请输入姓名:", "张三");
alert(str); 弹出框显示的就是:张三
A-4:状态栏
window.defaultStatus=" "; 这是属性、针对IE有效
window.defaultStatus = "测试数据";
window.status = "test";
A-5:时间间隔和暂停
setTimeout("函数/方法",延迟的毫秒数) 这个只执行一次
setTimeout("alert("点击确定")",1000); 在1秒之后弹出点击确定的框
setTimeout(function(){alert("123");},1000);
clearTimeout( ) 暂停执行
setInterval("函数/方法",延迟的毫秒数) 这个循环执行
clearInterval( ) 暂停执行
A-6:历史
window.history.go( ); 参数是返回的页数,正数为前进
history.back(); 前进一页
history.forward(); 后退一页
alert("在历史记录中有"+history.length+"页"); 查看历史中的页数
B:document对象
anchors 页面中所有锚的集合
forms 页面中表单的集合
images 页面中图像的集合
links 页面中所有链接的集合
标签:
原文地址:http://www.cnblogs.com/Rt-long/p/4811452.html