Skip to content

Instantly share code, notes, and snippets.

@konrad
Created March 22, 2012 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konrad/2157942 to your computer and use it in GitHub Desktop.
Save konrad/2157942 to your computer and use it in GitHub Desktop.
Pubmed search bookmarklet - search marked text in Pubmed
/*
Use this as a bookmarklet by saving it as a web browser bookmark. Then mark a piece of text in a page and click the bookmark. The marked text will be searched in Pubmed.
*/
javascript:(function(){
var selected_text = '';
if (window.getSelection){
selected_text = window.getSelection();
}
else if (document.getSelection){
selected_text = document.getSelection();
}
else if (document.selection){
selected_text = document.selection.createRange().text;
}
else return;
window.open('http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?term=' + selected_text,'Pubmed search');
})();
/*
A condensed version: javascript:(function(){%20%20%20%20%20var%20txt%20=%20'';%20%20%20%20%20%20if%20(window.getSelection)%20%20%20%20%20{%20%20%20%20%20%20%20%20%20txt%20=%20window.getSelection();%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20else%20if%20(document.getSelection)%20%20%20%20%20{%20%20%20%20%20%20%20%20%20txt%20=%20document.getSelection();%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20else%20if%20(document.selection)%20%20%20%20%20{%20%20%20%20%20%20%20%20%20txt%20=%20document.selection.createRange().text;%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20else%20return;%20%20%20%20%20window.open('http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?term='%20+%20txt,'Pubmed%20search');%20})();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment