JavaScript Window Screen
- Previous Page JS Window
- Next Page JS Location
Objek window.screen mengandung informasi layar pengguna.
Window Screen
window.screen Objek dapat ditulis tanpa awalan window:
Atribut:
- screen.width
- screen.height
- screen.availWidth
- screen.availHeight
- screen.colorDepth
- screen.pixelDepth
Lebar Layar Window Screen
screen.width
Atribut ini mengembalikan lebar layar pengunjung dalam piksel.
Example
Tunjukkan lebar layar dalam piksel:
document.getElementById("demo").innerHTML = "Lebar Layar: " + screen.width;
The result will be:
Ketinggian Layar Window Screen
screen.height
Atribut ini mengembalikan ketinggian layar pengunjung dalam piksel.
Example
Tunjukkan ketinggian layar dalam piksel:
document.getElementById("demo").innerHTML = "Ketinggian Layar: " + screen.height;
The result will be:
Lebar Layar Window Screen
screen.availWidth
Atribut ini mengembalikan lebar layar pengunjung dalam piksel, setelah mengurangi fitur antarmuka seperti toolbar jendela.
Example
Tunjukkan lebar layar tersedia dalam piksel:
document.getElementById("demo").innerHTML = "Lebar Layar Tersedia: " + screen.availWidth;
The result will be:
Ketinggian Layar Window Screen
screen.availHeight
Atribut ini mengembalikan ketinggian layar pengunjung dalam piksel, setelah mengurangi fitur antarmuka seperti toolbar jendela.
Example
Tunjukkan ketinggian layar tersedia dalam piksel:
document.getElementById("demo").innerHTML = "Ketinggian Layar Tersedia: " + screen.availHeight;
The result will be:
Kedalaman Warna Layar Window
screen.colorDepth
Atribut ini mengembalikan bilangan bit yang digunakan untuk menampilkan warna.
Semua komputer moden menggunakan resolusi warna perangkat keras 24 bit atau 32 bit:
- 24 bits = 16,777,216 jenis warna "True Colors"
- 32 bits = 4,294,967,296 jenis warna "Deep Colors"
Older computers use 14 bits: 65,536 different "High Colors" resolutions.
Very old computers and old mobile phones use 8 bits: 256 different "VGA colors".
Example
Display screen color depth in bits:
document.getElementById("demo").innerHTML = "Screen Color Depth: " + screen.colorDepth;
The result will be:
The #rrggbb (rgb) values used in HTML represent "True Colors" (16,777,216 different colors).
Window Screen Pixel Depth
screen.pixelDepth
The property returns the pixel depth of the screen.
Example
Display screen pixel depth in bits:
document.getElementById("demo").innerHTML = "Screen Pixel Depth: " + screen.pixelDepth;
The result will be:
For modern computers, color depth and pixel depth are equal.
- Previous Page JS Window
- Next Page JS Location