js獲取頁面的中可用的寬高
網頁可見區域寬: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
螢幕可用工作區寬度:window.screen.availWidth
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 相對文件的水平座標+垂直方向滾動的量
IE,FireFox 差異如下:
IE6.0、FF1.06+:
clientWidth = width + padding
clientHeight = height + padding
offsetWidth = width + padding + border
offsetHeight = height + padding + border
IE5.0/5.5: clientWidth = width - border
clientHeight = height - border
offsetWidth = width
offsetHeight = height
相關推薦
你真的懂js獲取可視區寬高嗎
可能你會覺得獲取可視區寬高不是很簡單嗎 原生js獲取高度不就是就window.innerHeight一句話的事,可是真的這麼簡單嗎 來看個測試頁面,如果頁面帶有橫向縱向的滾動條,我們打印出各個高度進行檢視對比 順便你也可以看看document.body和document.document
js獲取頁面中的滑鼠滾輪事件
附加事件 其中經我測試,IE/Opera屬於同一型別,使用attachEvent即可新增滾輪事件。 /*IE註冊事件*/ if(document.attachEvent){ document.attachEvent('onmousewheel
js獲取上傳圖片寬高
直接程式碼 <!DOCTYPE html> <html> <head> <title>獲取上傳圖片的寬高</title> </
js獲取頁面的中可用的寬高
網頁可見區域寬:document.body.clientWidth 網頁可見區域高:document.body.clientHeight 網頁可見區域寬:document.body.offsetWidth (包括邊線的寬) 網頁可見區域高:document.body.o
JS獲取瀏覽器中的各種寬高值
width: clientWidth:物件實際內容的寬度,不包含邊線,最大不超過視口寬度 offsetWidth:物件實際寬度,包含邊線,最大不超過視口寬度 scrollWidth:物件實際寬度,不包含邊線,可超過視口寬度 height:(都可超過視
js獲取頁面url中的各項值
js一、 通過window.location獲取各項參數1、獲取頁面完整的urlurl = window.location.href;2、獲取頁面的域名host = window.location.host;host2=document.domain; 應用場景:頁面跳轉,開發環境和測試環境域名不同,所以需要
activity 中獲取控件的寬高
post oncreate div ams getheight width 方式 return override 1.第一種方式: TextView textview3 = findViewById(R.id.textview3); textView3.post(new
js獲取url 中的值,並跳轉相應頁面
實現方法:一:獲取URL帶QUESTRING引數的JAVASCRIPT客戶端解決方案,相當於asp的request.querystring,PHP的$_GET1.函式:<Script language="javascript">function GetRequest() {var url = lo
js裡獲取html真實舞臺寬高
var winSize = {width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}; var winWidth = 0; var winH
在jsp頁面中js獲取java中變數的值
1。通過<%=java變數%>的方式賦值給js變數。 1、定義一個java變數 <% String a = "222";//定義一個string型別的java變數 %> 2、輸出給js var k = <%=a%>;輸出
JS中的寬高理解
一、 window 與document 的區別 1、window 物件表示瀏覽器中開啟的視窗 2、window 物件可以省略 1、document物件是window的一部分 2、瀏覽器中HTML文件成為document物件 二、window.locat
獲取圖片的真實寬高
body fse 裏的 on() alt 渲染 iss b2c data 獲取圖片高度,jq 用的是height() 獲取 寬度。jq用的是width()。 只是這個是渲染後的寬高,也就是css設置後的寬高 javascript 是offsetWidth of
js 獲取URL中參數
res 獲取值 參數名稱 var blog null match class query function getQueryString() { var result = location.search.match(new RegExp("[\?\&][^
js 獲取url 中的參數;
實例 pos 瀏覽器中 date toc 整數 調用方法 cap adding 用JS獲取地址欄參數的方法(超級簡單) 方法一:采用正則表達式獲取地址欄參數:( 強烈推薦,既實用又方便!) function GetQueryString(name) {
js獲取頁面地址
win 完整 class highlight window true bsp javascrip clas //獲取完整地址 window.location.href // 獲取域名 window.location.host; js獲取頁面地址
css中固定寬高div與不固定寬高div垂直居中的處理辦法
分配 css代碼 http min har 空間 -i dex round 固定高寬div垂直居中 如上圖,固定高寬的很簡單,寫法如下: 1 position: absolute; 2 left: 50%; 3 top: 50%; 4 width:200px;
js移動端插件iosSelect.js之頁面中多次使用該插件的問題
.cn 插件 sselect com 自己 his 但是 調用次數 select iosselect是在webapp下的一個picker組件,可以輕松實現各類選擇器效果。比如地區選擇 時間選擇 日期選擇等。網上教程是很多的,github詳解:https://github.
獲取屏幕的寬高
client defined efi nth logs cli return height width function client(){ if(window.innerHeight !== undefined){ return {
js獲取URL中指定的值
string 元素 每一個 cati 組元 brush func arc gets function getSearchString(key) { // 獲取URL中?之後的字符 var str = location.search; str = s
使用js獲取頁面的各種高度
title scroll 元素 scrollto all 滾動 包括 blank () 使用js獲取相關高度: 獲取網頁被滾動條卷去的高度——兼容寫法: scrollHeight = documen.body.scrollTop || document.docu