Created
March 22, 2012 12:04
-
-
Save konrad/2157942 to your computer and use it in GitHub Desktop.
Pubmed search bookmarklet - search marked text in Pubmed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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