« Firefox bookmarks | Main | CSS and Internet Explorer »

March 10, 2005

Popups from a bookmarklet

I use del.icio.us to store my bookmarks. There's a bookmarklet that I use to conveniently post pages to del.icio.us. However, with Firefox, the popup would always popunder, so I'd have to Alt-Tab to it every time.

Here's the original javascript for that bookmarklet from the del.icio.us post page (added line breaks).

javascript:q=location.href;p=document.title;
void(open('http://del.icio.us/markveerman?v=2&noui=yes&jump=close&
url='+encodeURIComponent(q)+'&title='+encodeURIComponent(p),
'delicious','toolbar=no,width=700,height=250'));

Here's the new javascript (added line breaks):

javascript:q=location.href;p=document.title;
w=window.open('http://del.icio.us/markveerman?v=2&noui=yes&jump=close
&url='+encodeURIComponent(q)+'&title='+encodeURIComponent(p),
'delicious','toolbar=no,width=700,height=250');
setTimeout('w.focus()',10); void 0;

This is pure conjecture, but I think the default behavior of Firefox is to put the focus back to the page you were currently on when running a bookmarklet. When I tried to just add w.focus(), it would popup the page for a millisecond, and then Firefox would put it back to the background. By adding a 10 millisecond timeout to the focus it allows Firefox to finish it's default behavior, and then I re-focus the post to del.icio.us popup.

Posted by mark at March 10, 2005 11:46 AM Subscribe (FeedBurner)

Comments

Thanks! I've been incredibly annoyed with that popunder behavior for months and months. Now I can fix it for my other bookmarklets as well.

(Found you through google, "bookmarklet popups" w/o quotes. You are second.)

Posted by: fuz at July 18, 2005 12:30 PM

Post a comment




Remember Me?

(you may use HTML tags for style)