Safari 4 breaks bookmarklets?

March 1, 2009 in Internet

Update 6/8/09: This still happens in the release version of Safari 4.

Update 6/13/09: More details available at Sakuzaku.

I have been unable to verify if this is a widespread problem or just my luck, but my Java bookmarklets are no longer working in the Safari 4 beta. Bookmarklets are mini-applications that can be run by a web browser.

Specifically, I use two bookmarklets to quickly resize my browser window in an attempt to solve my frustration with Mac OS X not having a proper “maximize” button. One bookmarklet makes the window take up the whole screen, the other makes the window smaller and recenters it. They sit in my bookmarks bar, and so resizing/recentering is just a click away (or, a command-1 or command-2 away — the only time I’ve ever appreciated that Safari chooses bookmarks, not tabs, in that manner). But suddenly in Safari 4, neither is working!

The maximize bookmarklet is:
javascript:self.moveTo(0, 0); self.resizeTo(screen.availWidth, screen.availHeight);

The small window bookmarklet is:
javascript:self.resizeTo(1024, screen.availHeight * .9);self.moveTo((screen.availWidth - 1024) / 2, screen.availHeight - screen.availHeight * .95);

Is anyone else having problems executing this code?

Edit (5 minutes later): And now it’s working again! Never mind! Maybe it was related to some hacking I was doing in Safari’s developer settings… more on that later if it turns out interesting.

Edit (10 pm): The problem is related to multiple tabs being open. Bookmarklets work fine with just one tab.

Similar Posts:

{ 1 trackback }

This is the Green Room » Progress in Safari 4
March 1, 2009 at 1:41 pm

{ 8 comments… read them below or add one }

1 peewee March 10, 2009 at 6:49 pm

Hi, same problem here. Bookmarklets work in a window with a single tab, but as soon as there is a second one they stop working. What kind of settings did you hack?

Reply

2 J March 11, 2009 at 9:54 pm

You’re right — it’s the tabs which are breaking it. I didn’t notice that before. The settings, unfortunately, had nothing to do with this…

Reply

3 w-cheese April 4, 2009 at 10:39 am

Same issue here. Please update if anyone finds a workaround.

Thanks!

Reply

4 Cody Robbins June 8, 2009 at 4:34 pm

This is apparently still broken in the final version of Safari 4.

Reply

5 Cody Robbins June 8, 2009 at 4:42 pm

There seems to be a WebKit bug filed for it (https://bugs.webkit.org/show_bug.cgi?id=24218), but there’s no action on it yet.

Reply

6 dcoregon June 30, 2009 at 1:37 am

I have the same problem, and I usually have a set of tabs I want to control. This all worked fine right up until version 4.

I didn’t get a valid WebKit bug id when I followed the above link.

More problems with Safari 4, relating to tabs:

I have some bookmarklets that let me operate on the current page, for instance:
javascript:void(document.location=’http://validator.w3.org/check?url=’+document.location)

Frequently I want the source page to stay up in a tab, so I’ll hold down my “apple” key when invoking the bookmarklet on the source page. In Safari 4, that has quit working. The bookmarklet still works, but it no longer looks for the Apple key down, or else ackt like it doesn’t. Luckily, I can just hit the back arrow while holding down the Apple key and I still can get it, so not so bad.

One more issue involving tabbed browsing: I have used “Saft” on MacOS for several years now, with no problems ever, but I had to remove it for the first time after upgrading to Safari 4, because doing an “open in tabs” from the bookmarks bar crashes Safari if Saft is installed.

Definitely some strangeness with tabbed browsing. Maybe some smart person will see what’s tying these problems together and get that thing fixed!

Reply

7 Cowicide September 5, 2009 at 8:00 pm

Same problem here with latest Safari 4.0.4 (5531.9) — This is really annoying…

Reply

8 stefankloss November 19, 2009 at 11:58 am

Hi, the bug might not be related to bookmarklets but to certain methods of the window/document/self-objects. Even in regular javascript resizeTo, moveTo, or other methods or properties setting position or size don’t work with multiple tabs open.

Reply

Leave a Comment

Previous post:

Next post: