|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is it possible to determine a visitor's monitor resolution setting using JavaScript?
|
|
#2
|
|||
|
|||
|
Hi Larry,
I'll give you an example of a script which will check the screen width and then will load the specific HTML according to the screen resultion: function BrowserCheck() { width = window.screen.width; if (width == 1024) {location.href="1024_file.htm"} else {location.href="800_file.htm"} } So window.screen.width refers to the horizontal amout of pixels ( most pc's are running 800x600 or 1024x768 ) Running this script requires a JavaScript 1.2 browser though ( e.g. MSIE 4.0 ) Hope this will help... |
|
#3
|
|||
|
|||
|
Hi Fas,
I alway thought the mosts browser give you wrong results. Do you know a compability list of browsers not only supporting JavaScript 1.2 but also reporting correct values of the screen resolution? Thanks, Ulf |
|
#4
|
|||
|
|||
|
Ulf,
just copy and paste the following script into a new HTML document: <html> <head> <script language="JavaScript1.2"> function Test() { width = window.screen.width; alert(width) } </script> </head> <body> <form> <input type="button" onClick="Test()"> </form> </body> </html> Clicking the button will show a javascript alert with the amount of horizontal pixels of your screen (most likely 800 or 1024)... I've tested it in both MSIE 4.0 and Netscape 4.5 and it worked fine! Grtz Fas |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Monitor's Resolution Setting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|