If 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.
javascript:self.moveTo(275,8);self.resizeTo(900,800);
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.
javascript:window.open('http://g5.local:8888',
'MyWindow','toolbar=no,location=no,directories=no,
status=no,menubar=no,scrollbars=yes,resizable=no,
width=320,height=418,left=100,
top=300');return%20false;
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.






0 Responses to “Set Safari Window Sizes with Bookmarklets”
Leave a Reply