Javascript高级程序设计--第8章笔记---窗口位置

来源:互联网 发布:刺客列传网络剧 编辑:程序博客网 时间:2024/05/13 18:30

窗口相对于屏幕左边和上边使用screenLeft和screenLeft

获取窗口左边和上边的位置

var  leftpos = (typeof window.sreenLeft == "number")?wndow.screenLeft : window.screenX;

var   topPos = (typwof  window.screenTo =="number")?window.screenTop:window.screenY;


窗口移动:

window.moveTo(0,0);

wndow.move(-50,0);//向左边移动50


窗口大小:

outerwidth outheight: 有些浏览器是返回浏览器高度宽度,有些浏览器返回该window容器的宽度 高度

innerwidth innereight:返回该window容器的宽度 高度

document.documentElement.clientWidth和document.documentElement.clienteight:页面视口的信息(标准模式下)

document.body.clientWidth和document.body.clienteight:页面视口的信息(混杂模式下)

所以获取页面视口大小:

var  pageWidth = windoe.innerWidth;

pageHeight = windoe.innerHeight;

if(typeof   pageWidth !="number"){

       if(document.compatMode==""CSS1Compact){

          pageWidth = document.documentElement.clientWidth; 

          pageHeight = document.documentElement.clienteight;

       }

}else{

         pageWidth = document.body.clientWidth;

          pageHeight =document.body.clienteight:

}


窗口大小的调整:

resizeTo(200,100)//调整到200*100

resizeBy()


窗口的打开:

window.open("http://www.baidu.com“,“topFrame”)//即在topFrame框架中加载这url文件,不存在就创建一个新的窗口或框架叫topFrame打开

第二个参数也可以是_self  _parent _top  _blank



阅读全文
0 0