Murphy Mac - Screencasts and Tutorials » Page 'Set Safari Window Sizes with Bookmarklets'

Set Safari Window Sizes with Bookmarklets


bookmarkletsIf you can’t get used to the green button for resizing your Safari windows you might like this. Your bookmarks can do more than just take you to a certain website. Using the capabilities baked into javascript you can create bookmarklets that not only open a page, they can also resize a window and set its location on the display.

But there’s more. You can get creative and coax bookmarklets into performing all kinds of tasks. For example, you could use a bookmarklet on your iPhone to search the content of a web page. Here’s a site listing dozens of bookmarklet ideas.

A bookmarklet is actually a clever line of javascript. A single line that is, just like your bookmarks. Here are two examples that Murphy uses. The first one resizes the window from which it’s clicked and positions it on the screen at a custom-set coordinate.


Right click here and select Copy Link Location to copy the code. Then you can paste it into TextEdit to change it. Or paste it into a bookmark and tweak it there to make a bookmarklet. Or keep it really simple: Drag the line of javascript to your bookmarks bar in Safari. See the screencast to watch Murphy do it.

You can adjust the numbers so the bookmarklet works for you. The first number-pair places the top left corner of the window 275 pixels from the left edge and 8 from the top. The second pair sizes the window 900 pixels tall, 800 wide.

Murphy uses this other bookmarklet to open a window for Remote Buddy, which he uses to control a remote iTunes library. A small window is suitable, and it doesn’t need toolbars or bookmarks at the top. The bookmarklet produces a tidy little window for selecting playlists and rating tracks.'http://g5.local:8888',





Right-click here to copy this code. It needs to be a single line and is only broken up here for convenience.

The http://g5.local:8888 is my G5 running iTunes. Change that to any url you need to open. The other settings are fairly self-explanatory. Murphy has the scrollbars on so he can scroll through his playlists. You can tweak those settings to meet your own needs.

Not all bookmarklets are created equal. You may need to trawl around a little to find the right javascript that works across multiple browsers. These two were only tested in Safari.

Watch Now | Permalink

3 comments to “Set Safari Window Sizes with Bookmarklets”

  1. I wonder if this works on Firefox as well. I use Firefox much more that Safari, and some pages auto re-size my browser for no apparent reason (other than to piss me off).
    I also started using remote buddy after you mentioned it on Twitter. What an awesome lil program. Now I could get speakers using an airport express into another room and control my iTunes via my iPhone. :) Bliss.

  2. Antonio, that first one works with Firefox. The second one might need a tweak.

  3. Hi Murphy,
    I was curious (especially since I’m terrible at javascript) if you knew a way to tweak your script to change your current window to match those dimensions and specifications and not a new pop up window. I’ve been playing with it and I really like using my gmail with it that way… Just curious!

Leave a comment