hta 窗口_如何获得HTA窗口的大小?

似乎没有属性或方法来获取该信息。现在发布的beta版IE9具有新属性outterWidth和outterHeight,但现在不是一个选项。

所以我为此设计了一个解决方法:

function addWinSizeGetterFuncs(){

var currViewportWidth = document.body.offsetWidth ;

var currViewportHeight = document.body.offsetHeight ;

resizeTo(currViewportWidth,currViewportHeight) ;

var chromeWidth = currViewportWidth-document.body.offsetWidth ;

var chromeHeight = currViewportHeight-document.body.offsetHeight ;

resizeTo(currViewportWidth+chromeWidth,currViewportHeight+chromeHeight) ;

window.getWidth = new Function('return document.body.offsetWidth+'+chromeWidth) ;

window.getHeight = new Function('return document.body.offsetHeight+'+chromeHeight) ;

}该函数的作用是为window对象创建两个新方法:window.getWidth()和window.getHeight()。他们将获得窗口的实际大小。

该函数需要存在body对象,因此必须在BODY标记之后执行。

现在我们就在这里,同样的问题适用于窗口位置。你无法获得实际的窗口位置。你可以得到的是相对于屏幕的视口位置。

所以同样的workaroud也适用于此:

function addWinPosGetterFuncs(){

var currViewportLeft = screenLeft ;

var currViewportTop = screenTop ;

moveTo(currViewportLeft,currViewportTop) ;

var viewportOffsetX = screenLeft-currViewportLeft ;

var viewportOffsetY = screenTop-currViewportTop ;

moveTo(currViewportLeft-viewportOffsetX,currViewportTop-viewportOffsetY) ;

window.getScreenX = new Function('return '+viewportOffsetX) ;

window.getScreenY = new Function('return '+viewportOffsetY) ;

}同样,该函数创建两个新方法来检索实际窗口位置:window.getScreenX()和window.getScreenY()

问题解决了。我会让你们弄清楚这个功能是如何工作的;)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值