advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
Tip of the Day
Average Rating: 1/5 | Rate this item | 1 user has rated this item.
Expertise: Intermediate
Language: Web
November 6, 2000
Optimize Your Pages For Users' Screen Resolution
You can never tell just what your users are going to do. Sometimes, their browser settings aren't quite optimal for your site, and you are forced to cater to the lowest common denominator. For instance, if you have a lot of data to display, it would be great to take advantage of the extra screen real estate provided by 1024x768 resolution, but this would alienate your 800x600 users.

You can design for 1024x768 resolution, but make sure to use cascading stylesheets for just about everything. Then, create a new stylesheet (or set of stylesheets) that will make your pages look OK on an 800x600 screen. Since everything will be bigger, you can shrink the font size and make many other optimizations.

Finally, take out the tags that reference the stylesheets. Add a script to the top of each page, right after the tag, like this:

 
  <html>
  <head>
  <script language=“javascript” src=“choose_css.js”> </script>

...And put this script (which works in IE4+ and NN 4+) in the choose_css.js file:

 
  // choose_css.js
  // -------------
  // choose the appropriate stylesheet according to
  // the user's screen resolution

  document.write(“<link rel='stylesheet' type='text/css' href='“);

  if (window.screen.height <= 600) {
    //resolution is 800x600 or less
    document.write(“small.css'>“);
  } else {
    document.write(“big.css'>“);
  }

Here's how it works: when the page starts to load, choose_css.js runs. If the screen is small (height <= 600), the stylesheet with smaller fonts is chosen. Otherwise, the stylesheet optimized for larger screens is chosen (the document.write() implementation is used to provide cross-browser compatibility.) You can even modify this to provide different stylesheets for any number of different screen resolutions (or browser capabilities, or whatever info you can get to through the DOM).

Chris McCann
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
advertisement
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES