One click resizing of browser window in MAC

January 4, 2007 at 2:23 am Leave a comment

One problem I faced with my new MacBook Pro was not being able to maximize, minimize (or custom size) and re-center the firefox window with a click of a button. So I found some interesting tips online and finally came up with this solution

  1. Maximize bookmark (This will maximize your window)
    javascript:self.moveTo(0,0);
    self.resizeTo(screen.availWidth,screen.availHeight);
  2. To actually get the maximum sizes of your window run this script (the reason is that the screen.availHeight is not the same as your screen resolution)
    function alertSize() {
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
      window.alert( 'Width = ' + myWidth );
      window.alert( 'Height = ' + myHeight );
    }

    Once you figure out the max dimensions here are some bookmarks you can add to get the job done

  3. Re-Center bookmark (If the screen width or height is not the same as the maximum resolution of your screen then use the values you got from the above script here. For example: my screen resolution is 1400 X 900 but the actual size of the document is 1400 X 749)
    javascript:var width = (screen.width - window.innerWidth) / 2;
    var height = (749 - window.innerHeight) / 2;
    self.moveTo(width, height);
  4. Custom size bookmark (with the window centered). In the example below I choose a 900 X 600 dimension for my window which you can replace with width and size of your choice.
    javascript:self.resizeTo(900, 600);
    var width = (screen.width - window.innerWidth) / 2;
    var height = (749 - window.innerHeight) / 2;
    self.moveTo(width, height);

This definitely works in FireFox and I assume it will also work in Safari with minor tweaks (like maybe using screen.availHeight instead of screen.height etc…)

NOTE: If you are a developer like I am and you are using FireBug or any other type of firefox extensions that take some space within the browser, then you might have to close or hide those extensions when running any of the scripts mentioned above. Otherwise the results may not be as expected for the obvious reasons.

Enjoy!

Advertisement

Entry filed under: Customization, Desktop, MAC. Tags: .

Serving fast and effective static content Learn by intuition

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 )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


 

January 2007
M T W T F S S
    Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

Flickr Photos

recess

More Photos

RSS TechCrunch

  • An error has occurred; the feed is probably down. Try again later.

Follow

Get every new post delivered to your Inbox.