Developing Matt

My Technical Journal

Set CSS based on Screen Resolution

with one comment

Coworker Wade was working with 1. getting screen resolution and 2. changing page size to fit that resolution. This turned out to be pretty tricky…a fluid mix of javascript, html, and vb. He ended up using a post by Serge Baranovsky to work a solution: 1. calling another page that sets a session variable to the screen resolution 2. calling back the original page. And once it’s in the session variable it can be used throughout. It’s not a perfect solution, but it is very quick and it works. Here is the zipped Screen Resolution source from Serge Baranovsky. There are other methods that should work, but all of them require a postback of some kind, as the resolution isn’t known until the page has loaded completely. Nice work Wade…and thanks for the extra help Serge!

Advertisements

Written by matt

September 25, 2007 at 9:32 am

Posted in Asp.net, javascript

One Response

Subscribe to comments with RSS.

  1. an easier way…set your panel(or control or whatever) to the right size based upon the screen.availHeight. compliments of wade….

    script type=”text/javascript” language=”javascript”

    document.getElementById(‘ctl00_Panel1’).style.height = screen.availHeight – 280;

    document.getElementById(‘ctl00_Panel1’).height = screen.availHeight – 280;

    /script

    matt

    October 25, 2007 at 7:31 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: