Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determine client screen resolution

Status
Not open for further replies.

vionca

MIS
Nov 19, 2003
60
US
Hi there,

Does anyone here know how to determine the client's screen resolution (800x600, 1024x768, etc) so that I can format a table accordingly?

Thanks,
Vionca
 
use <table width=&quot;100%&quot;>

you will save yourself so much effort and heartache

not to mention the user-hostile behaviour of forcing someone to maximize their browser window to avoid a horizontal scrollbar


rudy
 
Rudy has an excellent point. You really shouldn't care about the client's screen resolution... since few people actually run their browsers full-screen. It's a pretty arbitrary number to most users. I run my monitor at 1280x960, but rarely have my browsers open any larger than half my screen, for example.


That being said, to answer your question as it pertains to determining the user's screen resolution (for future reference beyond &quot;formatting a table accordingly), the only way we've found (short of some sort of java applet or OCX) is via javascript.
Code:
<script language=&quot;JavaScript1.2&quot;>
    var sUserScreenWidth = screen.width;
    var sUserScreenHeight = screen.height;
    var sUserAvailableWidth = screen.availWidth;
    var sUserAvailableHeight = screen.availHeight;
    var sUserColorDepth = screen.colorDepth;
</script>
then we frequently will use javascript to plug those values into forms that are already being submitted, and store them as client variables or store them into our own table for stats and other purposes.


-Carl
 
Heed Rudy's reply!

On the other hand if you're feeling rebellious or just curious, you use javascript for this type of thing.

<SCRIPT language=&quot;JavaScript&quot;>
document.write('width=' + screen.width +'<br>');
document.write('height=' + screen.height);
</SCRIPT>

One thing to keep in mind, the screen.height and screen.width will give you the screen resolution that the user is running his/her computer with - it doesn't necessarily give you the size of the active window.

 
thanks so much guys! I do realize there are repercussions, but in my particular situation, users that want to disply large amounts of data in this table will need to maximize their browsers. I would at least like to offer people using higher resolutions the option to view more data at a time than the rest.
 
Or provide some kind of &quot;inspector&quot; so that everyone can view complete information... regardless of screen resolution.

Provide the first several columns of essential information for a given record/row, and then offer a link/icon which opens a small pop-up window to view the record in more detail. Do it right and it'll be more efficient and user-friendly then displaying information in a wide table.


-Carl
 
Thank you Carl. I might need to use an inspector. That's sounds like the best approach considering my circumstances.
 
But don't users want to see everything all at once in the same window? &quot;I want to see it all, and I don't want to scroll... No, I'm not changing my 640x480 resolution....&quot;
[neutral]
I've lost count of the times requestors want to put ten pounds of information in a five-pound bag.

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
Boy howdy, my Liberal Studies degree really prepared me for this....
 
> I've lost count of the times requestors want to
> put ten pounds of information in a five-pound bag.

heh, good one

can you say &quot;portal&quot;?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top