知识总结4

57 阅读2分钟

window.scrollBy(100, 100); alert("pageXOffset: " + window.pageXOffset + ", pageYOffset: " + window.pageYOffset);//pageXOffset设置或返回当前页面相对于窗口显示区左上角的 X 位置。pageYOffset设置或返回当前页面相对于窗口显示区左上角的 Y 位置。

function openWin(){ window.open('','','width=200,height=100'); alert(window.parent.location); }//parent返回父窗口。

//screen对 Screen 对象的只读引用。请参数 Screen 对象 document.write("可用高度: " + screen.availHeight);//availHeight返回屏幕的高度(不包括Windows任务栏)

document.write("可用宽度: " + screen.availWidth);//availWidth返回屏幕的宽度(不包括Windows任务栏)

document.write("颜色深度: " + screen.colorDepth);//colorDepth返回目标设备或缓冲器上的调色板的比特深度

document.write("总高度: " + screen.height);//height返回屏幕的总高度

document.write("颜色分辨率: " + screen.pixelDepth);//pixelDepth返回屏幕的颜色分辨率(每象素的位数)

document.write("总宽度: " + screen.width);//width返回屏幕的总宽度

function openWin(){ myWindow=window.open('',''); myWindow.document.write("

这是'我的窗口'"); myWindow.document.write("
ScreenLeft: " + myWindow.screenLeft); myWindow.document.write("
ScreenTop: " + myWindow.screenTop + "

"); }//ScreenLeft返回相对于屏幕窗口的x坐标ScreenTop返回相对于屏幕窗口的y坐标

window.sessionStorage//sessionStorage在浏览器中存储 key/value 对。 在关闭窗口或标签页之后将会删除这些数据。

myWindow.document.write("
ScreenX: " + myWindow.screenX);//ScreenX返回相对于屏幕窗口的x坐标 myWindow.document.write("
ScreenY: " + myWindow.screenY + "

");//ScreenY返回相对于屏幕窗口的y坐标

function check(){ if (window.top!=window.self) { document.write("

这个窗口不是最顶层窗口!我在一个框架?

") } else{ document.write("

这个窗口是最顶层窗口!

") } }//self返回对当前窗口的引用。等价于 Window 属性。

window.status="一些文本在状态栏!";//status设置窗口状态栏的文本。

function check(){ if (window.top!=window.self) { document.write("

这个窗口不是最顶层窗口!我在一个框架?

") } else{ document.write("

这个窗口是最顶层窗口!

") } }//top返回最顶层的父窗口。

function myFunction(){ alert("你好,我是一个警告框!"); }//alert()显示带有一段消息和一个确认按钮的警告框。

window.atob(encodedStr)//atob()解码一个 base-64 编码的字符串。

window.btoa(str)//btoa()创建一个 base-64 编码的字符串。

window.blur()//blur()把键盘焦点从顶层窗口移开。

function myStopFunction() { clearInterval(myVar); }//clearInterval取消由 setInterval() 设置的 timeout。

function myStopFunction() { clearTimeout(myVar); }//clearTimeout取消由 setTimeout() 方法设置的 timeout。

function closeWin(){ myWindow.close(); }//close()关闭浏览器窗口。

var r=confirm("按下按钮!");//confirm()显示带有一段消息以及确认按钮和取消按钮的对话框。

var p=window.createPopup();//createPopup()创建一个 pop-up 窗口。

function openWin(){ myWindow=window.open('','','width=200,height=100'); myWindow.document.write("

这是'我的窗口'

"); myWindow.focus(); }//focus()把键盘焦点给予一个窗口。