window对象BOM

BOM的和新对象是window,他表示流浪器的一个实例,作为一个Global对象,有权访问parseInt()等方法

在全局作用域声明的变量,函数都有钱访问

            var a=20;
            function sayName () {
                console.log("Name");
            }
            console.log(window.a,a);
            window.sayName();

本来在全局定义的变量是不能删除的,但在window.a 定义的却可以删除

            var a=20;
            window.b=30;
            delete a;
            delete window.b;
            console.log(a,b);

窗口关系和框架

window.frames[0,1,2,,,,]

window.frames[name]

frames[0,1,2,,,]

frames[name]

		<frameset rows="160,*">
			<frame src="frame.htm" name="topFrame">
			<frameset cols="50%,50%">
				<frame src="anotherframe.htm" name="leftFrame">
				<frame src="yetanotherframe.htm" name="rightFrame">
			</frameset>
		</frameset>

  窗口位置

console.log(window.screenLeft,window.screenTop,window.screenX,window.screenY);

 两个移动窗口的代码(好像都被禁用

window.moveTo(a,b)
window.moveBy(a,b)

窗口位置

console.log(window.innerWidth,window.outerWidth,window.innerWidth,window.outerWidth);

调节窗口大小(在谷歌和火狐被禁了

            window.resizeTo(100,100);
            window.resizeBy(100,100);

超时调用(建议里面写函数

var a=setTimeout(function  () {
                alert("fuck");
            },3000);

间歇调用

            var a=setInterval(function  () {
                alert("fuck");
            },3000);

系统对话框

confirm(a)a代表问你的那句话

            if(confirm("fuck ok??")){
                alert("thx");
            }else{
                alert("fuck you");
            }

prompt(a,b)a 代表问你的,b 代表帮你填一些,如果关掉或者点否

            var a=prompt("what's your name","ken");
            if(a!==null){
                alert("welcome  "+a);
            }
原文地址:https://www.cnblogs.com/vhyc/p/5851023.html