HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 14th, 1999, 08:50 PM
Larry
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Is it possible to determine a visitor's monitor resolution setting using JavaScript?

Reply With Quote
  #2  
Old September 15th, 1999, 06:38 AM
Fas
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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...

Reply With Quote
  #3  
Old September 21st, 1999, 04:30 AM
Ulf Wendel
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #4  
Old September 21st, 1999, 02:00 PM
Faz
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Monitor's Resolution Setting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway