Do you own a laptop and are constantly switching back and forth between the internal LCD and an external monitor? Are you always wanting your web browser in the same spot? Well, then this tip is for you. We’re going to create a browser bookmarklet which will resize and position your browser to the same spot every time you click it. It will work in any browser and operating system.
It’s real simple; we’re just going to tweak the following line of code:
javascript:self.resizeTo(A,B);self.moveTo(C,D);
In section A you’ll want to put a pixel value for the width of the browser window. In section B, place a pixel value for the height of the browser window. Next, in section C insert a pixel value for the distance of the browser window from the left side of your monitor. Finally, in section D stick in a value for the distance from the top of the monitor.
Now just create a new bookmark, putting the code you just tweaked in the address field. You can save the bookmark anywhere in your browser, but it’s helpful to have it on the bookmark toolbar. Now just click the bookmark and your browser will go to the same spot every time. It will probably take some tweaking until you get it right, as every browser handles those values a little differently. If you want a place to start, you can use my code. I did my bookmarks using Firefox for Mac.
Here’s my bookmarklet for my MacBook (1280×800):
javascript:self.resizeTo(1220,690);self.moveTo(30,12);
Here’s my bookmarklet for my 19″ LCD (1280×1024):
javascript:self.resizeTo(1220,835);self.moveTo(30,52);
If you’ve tweaked your code to perfection on other resolutions and browsers, feel free to share it in the comments. I’m sure others will appreciate it.
4 Comments
Perfect, I knew there had to be some way to do it but I just didn’t know how.
Thanks.
Very handy tip. Thanks for this. I am continually having to tweak my browser size and position whenever sites decide to take control of my browser (I know I can disable window resizing, etc.).
In gecko browsers you can disable that javascript so naughty websites cant move your window without your say so. I have it disabled so I come up with a different solution for Camino. If you have CamiScript installed you can save the following as an applescript and run it with CamiScript.
set win to window 1 of application “Camino”
set pos to {224, 0, 1024, 746}
set bounds of win to pos
This puts my Camino widow pushed up against the right side of my screen with a width of 800px and with maximum height. (I am on a 12″ iBook with a screen res. of 1024×768). I assume that this technique may work with other applications however it is unconfirmed.
Eddie, I did have a script setup in Camino, but once I switched to Firefox it became useless. That’s why i did the bookmarklet thing.