站內搜尋:Yahoo搜尋的結果,如果沒有給完整的網址,請在站內再搜尋一次!

2023-02-21

用JavaScrip偵測螢幕尺寸,使用範圍、工作區、網頁可見區域、網頁內容全文...的大小

用JavaScript 取得螢幕裝置各項數值的指令

  1. 目前使用範圍的高、寬
    document.documentElement.clientHeight
    document.documentElement.clientWidth
  2. 網頁可見區域的寬、高
    document.body.clientWidth
    document.body.clientHeight
  3. 網頁可見區域的寬、高
    document.body.offsetWidth(包括邊線和捲軸的寬)
    document.body.offsetHeight(包括邊線的寬)
  4. 網頁內容全文的寬、高
    document.body.scrollWidth
    document.body.scrollHeight
  5. 網頁被捲而隱藏的高(FireFox)  (the number of pixels the body is scrolled) (垂直方向)
    document.body.scrollTop
    網頁被捲而隱藏的高(IE)
    document.documentElement.scrollTop
  6. 網頁被捲而隱藏的左側  (the number of pixels the body is scrolled) (水平方向)
    document.body.scrollLeft
  7. 網頁內容(Screen)在網頁視窗(Window)的上緣(y座標)
    window.screenTop
  8. 網頁內容(Screen)在網頁視窗(Window)的左緣(x座標)
    window.screenLeft
  9. 螢幕解析度的高、寬 (Ex. 1080*1980)
    window.screen.height
    window.screen.width
  10. 螢幕可用工作區高、寬  (Ex. 1032*1980)
    window.screen.availHeight
    window.screen.availWidth
  11. 螢幕的顏色深度(彩色位元數)  (Ex. 24)
    window.screen.colorDepth
  12. 螢幕的像素深度(像素位元數)  (Ex. 24)
    window.screen.pixelDepth
  13. 螢幕的X、Y方向解析度(像素/英寸)
    window.screen.deviceXDPI
    window.screen.deviceYDPI
  14. 螢幕的X、Y方向邏輯解析度(像素/英寸)
    window.screen.logicalXDPI
    window.screen.logicalYDPI

  15. window.screen.bufferDepth
  16. window.screen.fontSmoothingEnabled
  17. window.screen.updateInterval

沒有留言:

張貼留言