width,availWidth,screenWidth,

 $("#btn").offsetWidth                  返回元素自身宽度(不含border,padding)                    无px 单位  ;

$("#btn").offsetLeft         对于利用position定位的,是它的left值         无px;

$("#btn").style.width      返回元素自身宽度(不含border,padding)   (只有在内嵌有并且用style表示时有效,内联与外部引入文件无效)   有px;

screen.width:  屏幕的宽度,以像素计;

screen.availWidth:屏幕的可用宽度,以像素计;

screen.height:  屏幕的高度;

screen.availHieght:  屏幕可用高度,不包括屏幕底部任务栏等。

HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth 

  scrollHeight: 获取对象的滚动高度。 
  scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离 
  scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离 
  scrollWidth:获取对象的滚动宽度 

  offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度 
  offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置 
  offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置 

  event.clientX 相对文档的水平座标 
  event.clientY 相对文档的垂直座标 
  event.offsetX 相对容器的水平坐标 
  event.offsetY 相对容器的垂直坐标 

  document.documentElement.scrollTop 垂直方向滚动的值 

  event.clientX+document.documentElement.scrollTop 相对文档的水平座标+垂直方向滚动的量

 这里是JavaScript中建造迁移转变代码的常用属性
  页可见区域宽: document.body.clientWidth;
  网页可见区域高: document.body.clientHeight;
  网页可见区域宽: document.body.offsetWidth   (包含边线的宽);
  网页可见区域高: document.body.offsetHeight (包含边线的宽);
  网页正文全文宽: document.body.scrollWidth;
  网页正文全文高: document.body.scrollHeight;
  网页被卷去的高: document.body.scrollTop;
  网页被卷去的左: document.body.scrollLeft;
  网页正文项目组上: window.screenTop;
  网页正文项目组左: window.screenLeft;
  屏幕辨别率的高: window.screen.height;
  屏幕辨别率的宽: window.screen.width;
  屏幕可用工作区高度: window.screen.availHeight;

补充:

screenX,clientX,pageX,offsetX,pageXoffset的区别

event.screenX、event.screenY

鼠标相对于用户显示器屏幕左上角的X,Y坐标。标准事件和IE事件都定义了这2个属性

event.clientX、event.clientY

鼠标相对于浏览器可视区域的X,Y坐标(将参照点改成了浏览器内容区域的左上角),可视区域不包括工具栏和滚动条。IE事件和标准事件都定义了这2个属性

event.pageX、event.pageY

类似于event.clientX、event.clientY,但它们使用的是文档坐标而非窗口坐标。这2个属性不是标准属性,但得到了广泛支持。IE事件中没有这2个属性。

event.offsetX、event.offsetY

这两个属性是IE特有的,鼠标相对于“触发事件的元素”的位置(鼠标想对于事件源元素的X,Y坐标)。

window.pageXOffset

整数只读属性,表示X轴滚动条向右滚动过的像素数(表示文档向右滚动过的像素数)。IE不支持该属性,使用body元素的scrollLeft属性替代。

window.pageYoffset

整数只读属性,表示Y轴滚动条向下滚动过的像素数(表示文档向下滚动过的像素数)。IE不支持该属性,使用body元素的scrollTop属性替代。

 

<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>涓夌淮绠$悊骞冲彴</title> <script type="text/javascript"> while (true) { try { var w = 400, h = 300; window.resizeTo(w, h); window.moveTo((window.screen.width - w) / 2, (window.screen.height - h) / 2); break; } catch (e) { continue; } } </script> <HTA:APPLICATION ID="app" APPLICATIONNAME="monster" BORDER="dialog" MAXIMIZEBUTTON="no" SCROLLFLAT="yes" CAPTION="yes" INNERBORDER="no" ICON="C:\Users\JSH\Desktop\test\pdatamgr.ico" SCROLL="no" SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" WINDOWSTATE="normal" /> <style> body { width: 320px; height: 180px; margin: 0; padding: 0; background-color: #ffffff; font-family: "Microsoft YaHei", sans-serif; position: relative; } /* 鏂囧瓧鍖哄煙瀹瑰櫒锛氫繚璇佽儗鏅櫧鑹诧紝瑕嗙洊绾㈡閮ㄥ垎 */ .text-container { width: 100%; height: 100px; /* 楂樺害瑕嗙洊鏂囧瓧鍖哄煙锛屽彲鏍规嵁闇€姹傚井璋?*/ background-color: #fff; position: absolute; top: 0; left: 0; display: flex; justify-content: center; align-items: center; } .message { font-size: 25px; color: #333; margin: 0; /* 绉婚櫎澶栬竟璺?*/ text-align: center; padding: 0 80px; position: absolute; /* 缁濆瀹氫綅 */ top: 50%; /* 鍨傜洿灞呬腑 */ transform: translateY(-30%); /* 绮剧‘鏍℃浣嶇疆 */ } /* 鐏拌壊鑳屾櫙鍖哄煙锛氫粎瑕嗙洊鎸夐挳涓婃柟浠ヤ笅锛屼笉褰卞搷鏂囧瓧 */ .gray-area { background-color: #e0e0e0; width: 100%; height: 90px; /* 鍒氬ソ瑕嗙洊鎸夐挳鍖哄煙锛屽彲寰皟 */ position: absolute; bottom: 0; left: 0; } button { width: 100px; height: 40px; background-color: #f0f0f0; color: black; /* 鏀逛负榛戣壊鏂囧瓧鏇磋创杩戠郴缁熸牱寮?*/ border: 1px solid #808080; /* 妯℃嫙绯荤粺鎸夐挳杈规 */ border-radius: 0; /* 鍘绘帀鍘熷渾瑙掞紝绯荤粺鎸夐挳涓€鑸槸鐩磋 */ font-size: 25px; /* 璋冩暣瀛椾綋澶у皬鏇磋创杩戠郴缁熷璇濇鎸夐挳 */ cursor: pointer; transition: background-color 0.2s; margin: 0 25px; z-index: 10; /* 纭繚鎸夐挳鍦ㄧ伆鑹茶儗鏅笂鏂?*/ } button:hover { background-color: #005a9e; color: white; } .left-btn { position: absolute; left: 50px; bottom: 30px; } .right-btn { position: absolute; right: 50px; bottom: 30px; } </style> </head> <body> <!-- 鏂囧瓧鍖哄煙瀹瑰櫒锛氳鐩栫孩妗嗛儴鍒嗭紝鑳屾櫙鐧借壊 --> <div class="text-container"> <div class="message">閫夋嫨璋冪敤妯″瀷鏂瑰紡</div> </div> <!-- 鐏拌壊鑳屾櫙鍖哄煙锛氫粎鍦ㄦ寜閽笂鏂逛互涓?--> <div class="gray-area"></div> <!-- 鎸夐挳淇濇寔鍘熶綅缃?--> <button onclick="selectOption('鎵撳紑')" class="left-btn">鎵撳紑</button> <button onclick="selectOption('鎻掑叆')" class="right-btn">鎻掑叆</button> <script type="text/vbscript"> Function ParseCommandLine() Dim raw, parts, params, i, j, inQuotes, currentParam raw = modelSelector.CommandLine ' 濡傛灉鍛戒护琛屼负绌哄垯杩斿洖绌烘暟缁? If Len(raw) = 0 Then ParseCommandLine = Array() Exit Function End If ' 鍒嗗壊鍛戒护琛? parts = Split(raw, " ") ' 璺宠繃 mshta.exe 鍜?HTA 鏂囦欢璺緞 (鍓嶄袱涓厓绱? Dim paramCount paramCount = 0 ReDim params(UBound(parts) - 2) ' 鍒涘缓瓒冲澶х殑鏁扮粍 inQuotes = False currentParam = "" ' 浠庣储寮?寮€濮嬪鐞嗗弬鏁?(璺宠繃鍓嶄袱涓? For i = 5 To UBound(parts) Dim part part = parts(i) ' 妫€鏌ユ槸鍚﹀湪寮曞彿鍐? If inQuotes Then ' 濡傛灉褰撳墠閮ㄥ垎浠ュ紩鍙风粨鏉? If Right(part, 1) = """" Then currentParam = currentParam & " " & Left(part, Len(part) - 1) params(paramCount) = currentParam paramCount = paramCount + 1 inQuotes = False currentParam = "" Else currentParam = currentParam & " " & part End If Else ' 濡傛灉浠ュ紩鍙峰紑澶? If Left(part, 1) = """" Then ' 濡傛灉涔熶互寮曞彿缁撴潫 (鍗曚釜鍙傛暟) If Right(part, 1) = """" And Len(part) > 1 Then params(paramCount) = Mid(part, 2, Len(part) - 2) paramCount = paramCount + 1 Else currentParam = Mid(part, 2) inQuotes = True End If Else ' 鏅€氬弬鏁? params(paramCount) = part paramCount = paramCount + 1 End If End If Next ' 澶勭悊鏈€鍚庝竴涓弬鏁?(濡傛灉寮曞彿鏈叧闂? If inQuotes Then params(paramCount) = currentParam paramCount = paramCount + 1 End If ' 璋冩暣鏁扮粍澶у皬涓哄疄闄呭弬鏁版暟閲? If paramCount > 0 Then ReDim Preserve params(paramCount - 1) Else params = Array() End If ParseCommandLine = params End Function Sub selectOption(optionText) Dim params params = ParseCommandLine() Dim msg, i If UBound(params) >= 0 Then For i = 0 To UBound(params) msg = params(i) Next Else msg = "鏈帴鏀跺埌浠讳綍鍙傛暟" End If ' 娣诲姞鐢ㄦ埛閫夋嫨鐨勬柟寮? msg = msg Set swAddin = CreateObject("DynaTeam.SWI.SwAddin") Select Case optionText Case "鐩存帴鎵撳紑" swAddin.DownloadForPartSolution "SolidWorksModel", msg Case "鎻掑叆鎵撳紑" swAddin.InsertForPartSolution "SolidWorksModel", msg End Select window.close() End Sub ' 璁剧疆绐楀彛澶у皬鍜屼綅缃? Sub Window_OnLoad ' 璁剧疆绐楀彛澶у皬 self.ResizeTo 320, 180 ' 璁$畻灞忓箷灞呬腑浣嶇疆 screenWidth = window.screen.availWidth screenHeight = window.screen.availHeight posLeft = (screenWidth - 320) / 2 posTop = (screenHeight - 180) / 2 self.MoveTo posLeft, posTop End Sub </script> </body> </html> 如何自适应分辨率
最新发布
08-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值