How a Bookmarklet Saved My Life


Ahem.. well, ok, made it a lot easier anyway. I've been trying to hack this Drupal "blog this" bookmarklet to work a little more to my taste. It's saving me a LOT of time the way i have it, but im missing a couple of serious bits of functionality if anyone out there is a bit handy with Javascript?

Here's what i have so far...

javascript: u=document.location.href; t=document.title.replace(/\|/g,'::'); s='



And here's the trouble --- the focus() doesn't work, and in an ideal world, it would open in a new tab on firefox, not a new window.

I've broken it to several lines so it's halfway readable.

Can anyone help?


Not possible as bookmarklet

For security, bookmarklets don't have enough privileges to manipulate tabs, you would need to make it into an extension to do that; here's code to open, and focus a new tab, in case you decide do that:

var browser =
browser.selectedTab = browser.addTab("");

Thanks a lot nullbit, any

Thanks a lot nullbit, any idea on how to get the focus() working? the form's #id is 'edit[title]'?




to the end works for a second, then it seems something else (other javascript?) steals the focus again

BTW, I triggered a "suspicious input data" error on your site a few times fiddling with this; in case they get logged as hack attempts or something

Certainly looks that way, oh

Certainly looks that way, oh well, thanks for trying nullbit!

Have you tried...

...delaying the focus() bit using setTimeout("...whatever.focus()",1500) or something like that?

No clue if it would even work, but it often helps to delay bits of code to let other bits finish first... Just a vague thought.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.