You can SET the size of a HTA window but I can't find a way to GET its size.

All I can think of is reading document.body.offsetWidth and .offsetHeight, but those give you the viewport size not the actual window size.

Is it possible to know that?

解决方案

It seems there are no properties or methods to get that information. The now beta-released IE9 has the new properties outterWidth and outterHeight, but that is not an option for now.

So I devised a workaround for this:

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) ;

}

What that function does is to create two new methods for the window object: window.getWidth() and window.getHeight(). They will get the actual size of the window.

The function requires the existence of the body object so it has to be executed after the BODY tag.

And now that we are at it, the same problem applies for the window position. You can't get the actual window position. What you can get is the viewport position relative to the screen.

So the same workaroud serves for this as well:

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 screenLeft-'+viewportOffsetX) ;

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

}

Likewise, the function creates two new methods that will retrieve the actual window position: window.getScreenX() and window.getScreenY()

Problem solved. I'll let you guys figure out how the function works ;)

hta 窗口,如何获取HTA窗口的大小?相关推荐

  1. 从子窗口中获取父窗口的句柄例子

    HWND hTemp=::GetParent(this->GetSafeHwnd());//GetSafeHwnd()会返回当前窗口的句柄,GetParent(子句柄)这个函数将获得子句柄的父窗 ...

  2. jquery中在子窗口中获取父窗口的Input文本值

    1.父页面 <input type="hidden" name="billNo" id="billNo" value="${ ...

  3. 窗口信息获取器 Spy4Win v0.20b 中文绿色版

    软件名称:窗口信息获取器 Spy4Win v0.20b 中文绿色版 软件类别:国产软件 运行环境:Windows XP 软件语言:简体中文 授权方式:免费版 软件大小:1.67 MB 软件等级: 整理 ...

  4. selenium之浏览器弹出新窗口并在新窗口操作

    在一个页面上点击一个链接之后,并不是在当前页面上打开,而是重新打开一个新页面:这种情况下如何跳转到新的页面上操作? 首先,需要了解的是每个窗口都有句柄的,可以理解为浏览器窗口的唯一标识符,根据这个标识 ...

  5. 在框架内用top.layer.open方式打开的子窗口中调用父窗口方法

    1.父窗口方法 function add() { //相关语句 } 2.父窗口打开子窗口 ,其他属性设置参考layer API top.layer.open({ id: "父窗口ID&quo ...

  6. html中获取浏览器窗口宽度,JavaScript 获取浏览器窗口的大小

    简明现代魔法 -> JavaScript -> JavaScript 获取浏览器窗口的大小 JavaScript 获取浏览器窗口的大小 2010-04-16 程序演示: 获取浏览器当前窗口 ...

  7. jquery获取父窗口的元素

    $("#父窗口元素ID",window.parent.document).find("#man_id").val(); 对应javascript版本为windo ...

  8. Javascript 获取浏览器窗口中文档(视口)可用尺寸的方法

    摘要: 由于浏览器的差异,许多信息的获取都要考虑兼容性,窗口中文档可用尺寸是一个经常需要用到的信息,由于浏览器不同甚至版本不同,获取的方法也不一样,本文介绍的函数能够兼容各种浏览器,获取这一信息.同时 ...

  9. python获取窗口句柄_Python+selenium 获取浏览器窗口坐标、句柄的方法

    1.0 获取浏览器窗口坐标 python目录可找到Webdriver.py 文件定义了get_window_rect()函数,可获取窗口的坐标和大小(长宽),但出现"Command not ...

最新文章

  1. request.getSession()
  2. Windows 10 安装
  3. 三维数组地址计算_科学计算NumPy
  4. 使用Gson进行json数据转换list to json 和json to list
  5. 世界最厉害的14位程序员,你认识几个?
  6. pycharm运行模型时怎么设置权重?_使用AMP和Tensor Cores得到更快速,更节省内存的PyTorch模型...
  7. 玻璃质感_央美设计基础 | 造型基本功练习——玻璃质感训练
  8. 金融统计分析与挖掘实战3.3.1-3.3.3
  9. uni-app发布为H5页面白屏问题
  10. CentOS 6.5安装Tomcat-9.0.0.M19
  11. java 子串替换_Java中的多个同时子串替换
  12. python 压力测试
  13. 专门感染word文件的计算机病毒是什么,计算机病毒分类及详细介绍.doc
  14. re学习笔记(0) CG-CTF-re-3 py交易
  15. 工程项目管理系统-----装修装饰行业的管理软件
  16. ARM Linux 内核 panic 之cache 一致性 ——cci-400 cache一致互联
  17. python基础教程:__call__用法
  18. 邵柏庆与Ace Lead Profits Ltd.在英属维尔京群岛针对和利时自动化科技有限公司提起诉讼
  19. 抛开元宇宙,我们来聊聊音视频技术的未来
  20. libpq-fe.h:没有那个文件或目录

热门文章

  1. 基于TI TMS320F2837x系列的单/双核32位浮点MCU控制器+ Xilinx Spartan-6低功耗FPGA核心板
  2. 线结构光视觉传感器/线激光深度传感器标定工具
  3. 彩虹易支付插件后台结算、会员中心秒提现集成包(哆咪付接口)
  4. joomla QQ登录,微信登录,微博登陆,人人登陆,明道登录的第三方登录
  5. android textview 底部,设置TextView居于屏幕底部的方法
  6. vis.js网络拓扑图第一个demo,vis-network.min.js的下载
  7. 生成随机密码,验证码
  8. r77-Rootkit后渗透技战术分析
  9. 为什么结构体指针需要malloc申请空间
  10. RISC-V架构学习笔记