[Wikipedia-l] Netscape bookmarklet

Jimmy Wales jwales at bomis.com
Fri Dec 21 03:14:52 UTC 2001


I've formatted both of these for easy reading, in case some Javascript
geniuses can help us.

Axel's version (which ignores selected text):

javascript:
s=document.getSelection();
for(i=0;i<frames.length;i++){
	s=frames[i].document.getSelection();
	if(s)break;
	}
if(!s)void(s=prompt('Entersearch terms forWikipedia',''));
wikiw=open('http://wikipedia.com/'+(s?'search.fcgi?request='+escape(s):''));
wikiw.focus();

My version (which works on Netscape for Linux, not sure about others
yet):

javascript:
q=document.getSelection()
;for(i=0;i<frames.length;i++){
	q=frames[i].document.getSelection();
	if(q)break;
	}
if(!q)void(q=prompt('Enter text to search using Wikipedia. You can also highlight a word on this
web page before clicking Wikipedia.',''));
if(q)location.href='http://www.wikipedia.com/search.fcgi?client=magic_button&request='+escape(q)

---------

My version doesn't pop a new window for Wikipedia -- it just takes you
there.  His version pops a new window and gives it focus.  I prefer
mine, but perhaps other people would prefer his?

Also, mine works, but I'm not sure why his doesn't.



More information about the Wikipedia-l mailing list