Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A collection of bookmarklets to control Safari windows Web Browsers
I've seen other hints regarding Bookmarklets in Safari, and I figured I'd share a few that I've created to resize/reposition the browser window. Note: All "Clickable" Bookmarklet examples in this hint can be dragged directly into your Safari "Bookmarks Bar" to save them. Also, if you decide to manually enter them, all bookmarklets should be entered as ONE line. First, I created this "generic" bookmarklet:
javascript:function rsz(s,i,w,h,m){if(i.screenX<0||i.outerWidth>
w||i.outerHeight>h){s.moveTo(0,0);s.resizeTo(w,h)};if(m){s.moveTo(m==1?0:
screen.availWidth-w,0);};s.resizeTo(w,h);};rsz(self,window,
WIDTH,HEIGHT,H_ALIGN);
that has three user-modifiable parameters:

WIDTH: window width in pixels
HEIGHT: window height in pixels
H_ALIGN: align to one side of the screen (1 = left align, 2 = right align)

Just copy the Bookmarklet text above and change those three parameters to what you want. Special javascript values can be used as well, such as screen.availWidth for the full width of the screen and screen.availHeight for the full height of the screen.

Examples:
800,600,1: A left-aligned 800x600 window. - Clickable: 800x600
javascript:function rsz(s,i,w,h,m){if(i.screenX<0||i.outerWidth>
w||i.outerHeight>h){s.moveTo(0,0);s.resizeTo(w,h)};if(m){s.moveTo(m==
1?0:screen.availWidth-w,0);};s.resizeTo(w,h);};rsz(self,window,800,600,1);
800,screen.availHeight,2: A right-aligned 800xFull-Height window - Clickable: 800xFull
javascript:function rsz(s,i,w,h,m){if(i.screenX<0||i.outerWidth>
w||i.outerHeight>h){s.moveTo(0,0);s.resizeTo(w,h)};if(m){s.moveTo(m==1?0:
screen.availWidth-w,0);};s.resizeTo(w,h);};rsz(self,window,800,
screen.availHeight,2);
(Note: ignore, but don't change, the first two arguments in the rsz function call). Also, I use this simple bookmarklet to make my browser full-screen - Clickable: Full Screen
javascript:self.moveTo(0,0);self.resizeTo(screen.availWidth,
screen.availHeight);
Many people don't realize this (even though it was mentioned in a previous hint), but when you create bookmarklets like these and put them in the "Bookmarks Bar" that they are automatically assigned hotkeys, from left to right, Command-1, Command-2, etc.. and these hotkeys work regardless of the visibility of the Bookmarks bar.

I have my most commonly used Bookmarklets in there, and since I'm on a 12" PowerBook running an IM and IRC client, I am constantly moving the browser window around to make up for the lack of screen real-estate. With simple hotkeys I can change from Full-Screen to 800xFull R, to 800x600 R, etc. very quickly!

Here's a clickable list of some common sizes that you can drag into your Bookmarks Bar directly, if you so desire:

Left Aligned: 800x600 - 800xFull - 1024x768 - 1024xFull
Right Aligned: 800x600 - 800xFull - 1024x768 - 1024xFull

I have a few more cool bookmarklets in my arsenal, but I figured I'd share these first!
    •    
  • Currently 2.80 / 5
  You rated: 3 / 5 (5 votes cast)
 
[31,026 views]  

A collection of bookmarklets to control Safari windows | 18 comments | Create New Account
Click here to return to the 'A collection of bookmarklets to control Safari windows' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
OMG
Authored by: bipto on Jan 29, '04 11:08:12AM

LOVE this tip! Thanks!



[ Reply to This | # ]
A collection of bookmarklets to control Safari windows
Authored by: zedwards on Jan 29, '04 11:20:35AM

Yes, very nice. More please! :^) For the non-javascript people, how would one change the size, but not the position? What variable from the above would be moved? I am assuming that it has to do with the 0,0 location.



[ Reply to This | # ]
Bookmarklets that are moving as little as possible.
Authored by: pwever on Jan 29, '04 01:07:31PM
800 pixel wide, as tall as possible, staying as close to the current position as possible: *

javascript:self.moveTo(Math.min(self.screenLeft,screen.availWidth-800),0);self.resizeTo(800,screen.availHeight);
800 pixel wide, 600 pixel tall, staying as close to the current position as possible: **

javascript:self.moveTo(Math.min(self.screenLeft,screen.availWidth-800),Math.min(self.screenTop,screen.availHeight-600));self.resizeTo(800,600);


[ Reply to This | # ]
Wow!
Authored by: willbank on Jan 29, '04 12:53:49PM
Very cool hint.

In your assorted bookmarklets bag have you made one to swap which monitor the safari windows is on when in dual monitor mode?

If you have, please will you post it?

---
No, really. This is a healthy obsession.

[ Reply to This | # ]

or much shorter versions
Authored by: maczac on Jan 29, '04 02:10:28PM
Full height of screen (any monitor)

javascript:self.moveTo(40,0);self.resizeTo(860,screen.availHeight);
Full screen (any monitor)-->

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

---
Chris

[ Reply to This | # ]

or much shorter versions
Authored by: theocrates on Jan 29, '04 07:09:35PM

Love this resizing bookmarklet! One question, though: what value(s) would I alter if I didn't want to line up the browser exactly at the left or right edges?

I ask because I have my Dock on the left-hand side, and I'd like the browser to resize just past the Dock, not underneath it.



[ Reply to This | # ]
or much shorter versions
Authored by: CkB_Cowboy on Feb 03, '04 10:32:35AM
First, make sure you are using the latest version from my site (http://cowboyscripts.org/) .. once you've generated the one you want, bookmark it and then edit the bookmark.

Find the part that says b%2?0 and change the 0 to something more suitable, like 40.

That should do the trick!

- Cowboy

---
My ill-matic homepage:
http://rj3.net/cowboy/

[ Reply to This | # ]

or much shorter versions
Authored by: kd8cyb on Mar 25, '08 07:57:26PM
In Safari 3.1
javascript:self.moveTo(0,0);self.resizeTo(screen.width,screen.height);
or
javascript:self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);
leave a gap of 4 pixels from wherever the Dock is positioned. Is there a away around this?

[ Reply to This | # ]
Mozilla too
Authored by: ssevenup on Jan 29, '04 03:00:45PM

Cool, and since it works in Mozilla I imagine it works in most browsers.

---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
A collection of bookmarklets to control Safari windows
Authored by: azadam on Jan 29, '04 03:34:53PM
Craziness. Less than 250 characters of code to accomplish what the zoom button should do.

Thanks much :) You've saved much much window adjustment and sizing angst.

[ Reply to This | # ]
A collection of bookmarklets to control Safari windows
Authored by: CkB_Cowboy on Jan 29, '04 03:37:37PM

After I submitted this tip, I actually got a little bored so I created a generator for these browser sizing/aligning Bookmarklets.

I've posted those and a few other Bookmarklets on my scripting site:

http://cowboyscripts.org/?page=bookmarklets

- Cowboy

---
My ill-matic homepage:
http://rj3.net/cowboy/

[ Reply to This | # ]

A collection of bookmarklets to control Safari windows
Authored by: CkB_Cowboy on Jan 29, '04 03:41:46PM

...and I've updated the code a little bit, it now works around a small issue in Safari that limits when you can resizeTo() a window. Get the updated code on my site :)

- Cowboy

---
My ill-matic homepage:
http://rj3.net/cowboy/



[ Reply to This | # ]
A collection of bookmarklets to control Safari windows
Authored by: brain13 on Jan 29, '04 06:23:43PM

Been looking for something like this for quite a while!!! Excellent!!!

Im not good at java...anybody has something like this that can make the adress bar go away? maybe all of the bars....???

thanks!



[ Reply to This | # ]
Java not= Javascript
Authored by: soufle on Feb 01, '04 03:33:34PM

FYI

Please note Java and Javascript are not related other than in name. While Javascript tries to use commands with the same names they were developed independently.


---
The box said windows XX or better so I got a Mac!



[ Reply to This | # ]
Java != Javascript
Authored by: raimondious on Feb 09, '04 01:21:39AM

Wasn't JavaScript Micro$oft's response to Java? I think they were afraid of a language that didn't need a specific OS or browser, since that would hurt their control over the market, so they made JavaScript so people would use it, and be forced to continue to use IE, since they also controlled how JS could be implemented. I dunno -- just something I heard.

---
One of the many advantages of being cool like me is that you don't get eaten by cannibals!



[ Reply to This | # ]
Java != Javascript
Authored by: elrocco on Mar 03, '04 01:41:22PM

Javascript has nothing to do with Microsoft...

Javascript was developed by Netscape.

Please read: http://www.oreillynet.com/pub/a/javascript/2001/04/06/js_history.html



[ Reply to This | # ]
A collection of bookmarklets to control Safari windows
Authored by: mmmmark on Jan 29, '04 10:58:16PM
Here are my two all-time favorites: Send Current Page URL in Default Mail App
javascript:location.href='mailto:?SUBJECT='+document.title+'&BODY='+escape(location.href)
Show Images on Page and Pixel Sizes
javascript:n='';for(i=0;i%3Cdocument.images.length;i++)%7Bn+='%3Cimg%20src='+document.images%5Bi%5D.src+'%3E%20'+document.images%5Bi%5D.width+'x'+document.images%5Bi%5D.height+'%3Cbr%3E%3Cbr%3E'%7D;if(n!='')%7Bdocument.write('%3Cp%20style=font-size:11px;font-family:verdana,sans;%3E'+n+'%3C/p%3E');void(document.close())%7Delse%7Balert('i%20see%20no%20images')%7D


[ Reply to This | # ]
A collection of bookmarklets to control Safari windows
Authored by: brain13 on Feb 02, '04 11:40:48AM

ok...ummmm...errr...sorry?



[ Reply to This | # ]