Resize and Reposition Your Browser with JavaScript

resize-browser Don’t you have it when you have lost your perfect spot for your browser window in your desktop layout and you have to put it back by dragging it over, then resizing each corner till it is back in that perfect spot yet again?  Well, with the help of a little JavaScript you can take the mess out of resizing and repositioning your browser.

Why Resize and Reposition Firefox Automatically?

When working I usually like to keep up a chat window, a notepad program and Firefox.  The notes and chat can stay a little smaller, stacked on top of each other on the side but Firefox needs to be in the left over big space.  So this is the JavaScript I used to put in in its spot:

javascript:resizeTo(1024,1000);self.moveTo(640,10);

That says to keep the browser 1024 in width, 1000 pixels high and to move to to the desktop location of 640 pixels left and 10 pixels down.  If you used:

javascript:resizeTo(1024,1000);self.moveTo(0,0);

That would set it up to be in the top left corner.  Depending on your screen size those last two numbers are what you want to change to get the position right and the first two number would be your browser size.  There is probably some mathematical way to figure out the right number for the position you want – but if your like me you just changed the numbers around till you got it in the position you need.  What if you wanted the browser height to be all the way from the top of the screen to the bottom?  In that case you could change the second number in resizeTo (in both examples that would be the 1000) to screen.availHeight.

javascript:resizeTo(1024,screen.availHeight);self.moveTo(0,0);

Notice now that by copy and pasting this into your address bar and hitting enter will make the browser as tall as it can be, with the width of 1024 pixels and in the left side of the screen.

How do You Create the Resizing Bookmark?

Now how can you create a bookmark to do this in Firefox?  Simple.  Right-click on your bookmarks toolbar, and select “New Bookmark”.  Name can be anything.  I call mine – Resize Browser.  Location is where you want to type in the JavaScript string above.  In keyword, type in a simple tag such a “r” or “resize”.  That way when you type in “r” into the address bar – it will automatically resize Firefox back to your perfect location.   Description can be left blank.  Hit the Add button, and you are done.

In the memory of every great cooking show I have ever seen, let me take a page out of their book and give you a link to drag into your bookmark toolbar so you can see the effects of this simple desktop organizational hack:

Now I know somebody will bring up the fact that a number of extensions will do this same action too.  This provides a way of simply adding the feature in without the need of another add-on.

javascript-settings Having Problems? 

To use these JavaScript tips, remember you have to have JavaScript enabled in your Firefox options.  Go to Tools > Options and then the Content Tab.  Make sure there is a check mark next to “Enable JavaScript”.  Also, in the Advanced settings be sure to allow scripts to move or resize existing windows.

With a little help from JavaScript and some creativity you will never lose your favorite browser size on your desktop.

, , , , ,

Comments are closed.