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
- Maximize bookmark (This will maximize your window)
javascript:self.moveTo(0,0); self.resizeTo(screen.availWidth,screen.availHeight); - 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
- 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); - 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!
Entry filed under: Customization, Desktop, MAC. Tags: .

Trackback this post | Subscribe to the comments via RSS Feed