Hi,

I'm trying to create a bookmarklet similar to the ones used for delicious.com. I want to be able to highlight and grab some text on a page, hit the bookmarklet button, go to the weblinks add/node/weblinks, automatically have the title and urls fields filled.

javascript:q=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);location.href='http://mysite.com/commons1/node/add/weblinks?edit[url]='+encodeURIComponent(location.href)+'&edit[link name]='+encodeURIComponent(document.title)+'&edit[link description]='+q

Any ideas?

Thanks,

Jim

ps I found the http://drupal.org/project/prepopulate module and it works great for grabbing the title and text as well as the url in a non weblinks content type. It picks up cck fields as well. In other words, I have this almost working with weblinks. The only thing I'm not getting is the url. Here's the code:

javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(%22http://www.mysite.com/commons1/node/add/page?edit[title]=%22+escape(t)+'&edit[body_field][body]='+escape(s)+'&edit[field_url][0][value]='+escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));

any ideas?

Thanks, Jim

Comments

walker2238’s picture

Try [url] instead of [field_url]

mcmcslp’s picture

For those interested, I found the following works:

javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(%22http://www.example.com/node/add/weblinks?edit[title]=%22+escape(t)+'&edit[body_field][body]='+escape(s)+'&edit[url]='+escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));
mcmcslp’s picture

Issue summary: View changes

updated to show partial solution.