Appropedia needs your support - Please Donate Today

Search bookmarklets

From Appropedia
Jump to: navigation, search

This began as a post on the Appropedia Foundation blog.

Highlight text on a web page, click a button on your bookmarks toolbar, and perform a search for that term on Appropedia. Sound handy? Here's how you make the button (I'm using Firefox, but I think it will work similarly on other browsers):

  1. Copy the following code to your clipboard (i.e. highlight and press Ctrl-C):
    javascript:(function(){q=document.getSelection();%20if(!q){void(q=prompt('Appropedia%20keywords:',''))};%20if(q)location.href='http://www.appropedia.org/Special:Search?search='+escape(q)})()
  2. Right click on an empty space on your bookmark toolbar. (If there is no empty space, rightclick the ">>" symbol at the right end of the toolbar.)
  3. Choose "New Bookmark" and enter a name such as "Appropedia". (I use "Ap" so it uses less space.)
  4. Paste the code from clipboard (Ctrl-V) into the "Location" field.
  5. Click the "Add" button. This will create the button - if you wish, you can drag and drop to a different place on the toolbar.

How do we link these?[edit]

I'd rather just give a links to drag and drop, but creating javascript links in Wordpress or in MediaWiki is beyond me. If you know how, please help us out, so we could add this to the front page of the wiki, and put them in blog posts.

You can do the same thing with other wikis, e.g. this is the code for the French language Ekopedia:

javascript:(function(){q=document.getSelection();%20if(!q){void(q=prompt('Ekopedia%20keywords:',''))};%20if(q)location.href='http://fr.ekopedia.org/Special:Search?search='+escape(q)})()

And this is for Wikipedia:

javascript:(function(){q=document.getSelection();%20if(!q){void(q=prompt('Wikipedia%20keywords:',''))};%20if(q)location.href='http://en.wikipedia.org/w/wiki.phtml?search='+escape(q)})()

Making your own bookmarklet[edit]

Or do you want another wiki or website? Easy - the following method has worked for any MediaWiki site I've tried. (It should work for most other sites as well, though you may have to adjust it a little.) Let's take [Greenlivingpedia:|Greenlivingpedia] as an example. Just go to the site and search for something that you isn't a page title in the wiki, such as qwerty. Then look at the url:

http://www.greenlivingpedia.org/Special:Search?search=qwerty&go=Go

Just delete the search term (qwerty), and anything after it, giving you:

http://www.greenlivingpedia.org/Special:Search?search=

Now, in the original code for Appropedia, at the beginning of the post, replace the appropedia.org search url in the code ("http://www.appropedia.org/Special:Search?search=") which is inside single quote marks, with the new site's search url. Leave the single quote marks there, so you replace 'http://www.appropedia.org/Special:Search?search=' with 'http://www.greenlivingpedia.org/Special:Search?search=' - then just replace the "prompt" term in the code with something appropriate (e.g. just change Appropedia to Greenlivingpedia, so 'Appropedia%20keywords:' becomes 'Greenlivingpedia%20keywords:' ).

So, putting the changes in italics, you now have:

javascript:(function(){q=document.getSelection();%20if(!q){void(q=prompt('Greenlivingpedia%20keywords:',''))};%20if(q)location.href='http://www.greenlivingpedia.org/Special:Search?search='+escape(q)})()

Hat tip: Geek to Live: Ten Must-Have Bookmarklets, by Gina Trapani, Oct 5 2005. This gave the code for the Wikipedia lookup bookmarklet.

Sites without a suitable search function[edit]

NOTE: These instructions are not working, and I'm not sure why. Nothing happens when clicking the bookmarklet, regardless of whether there is a "+" on the end of the search url in the code. ' --Chriswaterguy 21:53, 4 March 2009 (UTC)

You can also use a search engine - either because you can't get the site search to work, or you prefer it for whatever reason. Just replace the search url with this.

http://www.google.com/search?q=site%3Asiteurl

...where siteurl is the address of the website you want to search. Remember that if you don't add a prefix (e.g. appropedia.org) then it will include all subdomains. If you use a prefix (e.g. www.appropedia.org) then it won't search other subdomains (e.g. blogs.appropedia.org).

So, for aidg.org, for example, the search url would be:

http://www.google.com/search?q=site%3Aaidg.org+

and the bookmarklet would look something like:

javascript:(function(){q=document.getSelection();%20if(!q){void(q=prompt('Greenlivingpedia%20keywords:',''))};%20if(q)location.href='http://www.google.com/search?q=site%3Aaidg.org'+escape(q)})()