Javascript Width Sniffing for Floats

Dunstan uses Javascript to sniff for browser width, take scope of the browser’s window dimensions, check for the amount of screenspace, and determine whether to use a one-column list [with the width of the list items allowed to flow across the width of the parent container] or a two-column list [with the width of the list items fixed to allow the columns to float nicely].

I can think of some interesting tangential applications to that. If you got really anal about this and had a few design elements that you wanted to appear one way in a large browser window but another way in a smaller one, you could certainly do it. Differentiation by browser screenspace may not be easy, but it’s slick.

[Dunstan has since updated the script based upon reader input ... and once again for good measure.]

Posted March 26th, 2004 in Geekery by Geof F. Morris.

Leave a response:

Note: This post is over 5 years old. You may want to check later in this blog to see if there is new information relevant to your comment.

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.