js的window对象与方法

一、window对象

  window对象 是BOM中所有对象的核心。BOM    Browser  Object Model
二、window属性

    1.(位置类型-获得浏览器的位置)
      IE:
       window.screenLeft
       可以获得浏览器距屏幕左上角的左边距  
        window.screenTop
       可以获得浏览器距屏幕左上角的上边距

      FF:  
        alert(screenX)  
         alert(screenY)

//IE
左边距
alert(screenLeft)
上边距
alert(screenTop)

//FF
左边距
alert(screenX)
上边距
alert(screenY)

       (获得浏览器的尺寸)

      FF:window.innerWidth  获得窗口的宽度
         window.innerHeight  获得窗口的高度

//FF:
alert(window.innerWidth);
alert(window.innerHeight);
//IE:
alert(document.documentElement.clientWidth)
alert(document.documentElement.clientHeight)

js中分为两种窗体输出:模态和非模态.window.showmodaldialog(),window.showmodeless()

showmodaldialog(”url”[,arguments][,features])

js中指定当前打开窗口的父窗口:window.opener,支持opener.opener…的多重继续. 

window.open(), (打开窗口)
window.close(), (关闭一个窗口)
window.self()(窗口本身)  
window.focus()(使当前的窗口在所有窗口之前. )
window.status=”内容” (js中状态栏显示内容:)
window.navigate(”http://www.google.com”); (js中的窗口重定向:)
window.print() (js中的打印:)
window.prompt(”message”,”defaultreply”); (js中的提示输入框:)
window.scroll(x,y) (js中的窗口滚动条)
window.scrollby(js中的窗口滚动到位置:)
window.history.back()返回上一页,window.history.forward()返回下一页,
window.history.go(返回第几页,也可以使用访问过的url) 

window.location的属性:

protocol(http:),

hostname(www.example.com)

port(80)

host(www.example.com:80)

pathname(”/a/a.html”)

hash(”#giantgizmo”,指跳转到相应的锚记)

href(全部的信息) 


window.location.reload()(刷新当前页面.)

window.location.href=”url” (指定当前显示链接的位置)

parent.location.reload()刷新父亲对象(用于框架)

opener.location.reload()刷新父窗口对象(用于单开窗口)

top.location.reload()刷新最顶端对象(用于多开窗口)

猜你喜欢

转载自blog.csdn.net/qq_35029061/article/details/82820902
今日推荐