Change width with JavaScript

AddThis Social Bookmark Button

I decided to write another post about manipulating css code with JavaScript. Yesterday, I wrote about allowing the viewer to easily change the font size. The same JavaScript code can be changed a little to make other cool changes to the look and feel of your web design. If you are making a website with fixed width it’s a good idea to stay with the 800px standard because there is a ton of people still out there with crappy monitors/resolution. However, many of your viewers will be using really high resolution so you might want to offer a resize button on your site along with the text change button.
 
If you are using fixed width and css you defined the width of your body or div tag to a certain number in your stylesheet. Let’s say you really like the way your design looks like at 1200px so you set the body width in your stylesheet to 1200px. This is how your website will load for everyone. To make the low resolution people happy, however, you add a button to resize your width to 800px. Use the simple code and this will work for WordPress or any other blog or website.
 
Between your <head> and </head> tags add the following JavaScript:

 
That’s it. Enjoy!

Popularity: 18%


Tags:


If you enjoyed this post, please consider to leave a comment.

Comments

No comments yet.

Leave a comment

(required)

(required)