WoW Insider is getting ready for BlizzCon!

Firefox, bookmarklets, and hidden windows

One nuisance I've lived with since switching to Firefox a year or so ago was that pop-up windows opened by bookmarklets tend to open behind the browser window rather than in front of it. This meant that clicking on my most frequently-used bookmarklets (one to post to WordPress and one to post links to del.icio.us) required an extra step to bring the window to the front. This is no big deal, so I lived with it for a long time.

Some time last week I reached a peak of frustration with this little quirk, and I had lots of real work to avoid doing, so I decided to find a solution. A google search found a few things like this ask Metafilter thread that suggested that it only happened for some people, and changing some Firefox settings may help. Nothing worked for me, and it happens the same way on my Windows XP and MacOS X machines.

I next tried adding various .focus() method calls to the bookmarklets, but the windows stubbornly remained in the background. Next I tried adding modal=yes to the window.open parameters. This worked in Windows, but did nothing on the Mac, and I didn't really want the window to be modal anyway.

To make a long story short, I found Mozilla Bug 232605, which describes exactly this problem. There are some patches, including one by bookmarklet pioneer Jesse Ruderman, one of which will undoubtedly be rolled into a future Firefox release.

In the meantime, I don't want to compile my own version of Firefox, so I tried to find a workaround. According to the bug comments, the problem is that the opening browser window is stealing the focus shortly after loading the URL, so I tried adding a timeout to steal it back:

javascript:setTimeout("x99.focus()",100);x99=window.open…

Hallelujah!  This works, so try it if you're having problems with hidden bookmarklet windows. You may have to vary the "100" value depending on your system—a timeout of 100 (1/10 second) works fine on my Windows box, but on the iBook it didn't work reliably until I increased the timeout to 1000 (one second). This delay is a bit disconcerting, but the URL usually takes a second to load in the pop-up window anyway, so it's not wasted time.

(The two hours it took me to figure out this technique that will save at most a few seconds per day might be wasted time, but we won't talk about that.)

Reader Comments

(Page 1)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Other Weblogs Inc. Network blogs you might be interested in: