Blog This - bookmarklet for Drupal 6

drupal

Often, while reading a web page, I will find something worth mentioning here on my site. The code below builds a Bookmarklet that makes a new blog entry with a prepopulated title and whatever text I have highlighted in the browser quoted in its body. This code also depends upon the Drupal Prepopulate module to get the job done.

This version launches in a blank tab or page:

jaνascript: 
u = document.location.href;
t = document.title;
s = '\n' + window.getSelection() + '\n';
pre = 'From%20' + encodeURIComponent(t) + encodeURIComponent(': %20');
void(window.open(
  '/journal/node/blog?edit[title]=' + encodeURIComponent('Link: ' + t) +
  '&edit[body_field][body]=' + pre + encodeURIComponent(s) + encodeURIComponent('Link')
));

This version launches in a sized popup window:

jaνascript: 
u = document.location.href;
t = document.title;
s = '\n' + window.getSelection() + '\n';
pre = 'From%20' + encodeURIComponent(t) + encodeURIComponent(': %20');
void(window.open(
  '/journal/node/blog?edit[title]=' + encodeURIComponent('Link: ' + t) +
  '&edit[body_field][body]=' + pre + encodeURIComponent(s) + encodeURIComponent(' Link'), 
  '_blank', 
  'width=710,height=500,status=yes,resizable=yes,scrollbars=yes'
));

Previous Post Next Post