Layar jendela.lebar
Contoh
Dapatkan lebar total layar Anda:
let width = screen.width;
Lebih banyak contoh "Coba Sendiri" di bawah ini.
Definisi dan Penggunaan
Properti width
mengembalikan lebar total layar pengguna.
Properti width
mengembalikan lebar dalam piksel.
Properti width
ini hanya-baca.
Catatan
Gunakan properti height untuk mendapatkan tinggi total layar pengguna.
Sintaksis
screen.width
Nilai Kembali
Jenis | Keterangan |
Sebuah angka | Lebar total layar pengguna dalam piksel. |
Lebih Banyak Contoh
Semua properti layar:
let text = "Total width/height: " + screen.width + "*" + screen.height + "<br>" +
"Available width/height: " + screen.availWidth + "*" + screen.availHeight + "<br>" +
"Color depth: " + screen.colorDepth + "<br>" +
"Color resolution: " + screen.pixelDepth;
Dukungan Peramban
screen.width
didukung di semua browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |