View Single Post
Old 01-29-12, 06:34 PM   #7
Ilmars
Swabbie
 
Join Date: Dec 2011
Posts: 5
Downloads: 220
Uploads: 0
Default

You can create a bookmark that will pop up a text box to submit a search term to google while browsing a the web page of a site. In order to do that try the following, it assumes a PC running Firefox, but can be configured to whatever browser you prefer.

First, browse a web page and create a bookmark for it. It doesn't matter what the page is, all we are doing is creating a bookmark to work with.

Next, click on the Bookmarks menu item in Firefox and locate the bookmark for the page you just created. Move your cursor to it and right click, then select Properties.

In the properties window you will see a "Name:" field and a "Location:" field. Enter a string like "Web page search" in the name field to give your bookmark a meaningful title.

Now copy the following snippet of code and paste it into the "Location:" field:

javascript:q%20=%20prompt("Enter%20a%20search%20ph rase:",%20"");%20if%20(q!=null)%20location=("http://www.google.com/search?num=100&q=site:"%20+%20escape(location.host name)%20+%20"%20\""%20+%20escape(q.replace(/\"/g,""))%20+%20"\"").replace(/%20/g,%20"+");%20void%200


Next press the Save button.

Note that there should be no spaces in the string that you pasted into the "Location:" field.

To execute a search on any web page, just browse to the web page and select the bookmark you created for the Web page search. It will pop up a text box that lets you enter a term to search for. It will pass the term surrounded by quotes to google, and position you to the google results page. You can further refine the term in the results page if you want. For example, you can add terms, or remove the quotes if you want an "OR" relationship.

I found that some forums (not necessarily subsim's) sometimes have problems with their embedded search utility, and this method sometimes returns more results than their embedded utility does.

Note that this code will search from the parent root of the web page you are on and drill down from the top, not from the position that you are located at.

Cheers,
Ilmars

Last edited by Ilmars; 01-29-12 at 09:25 PM.
Ilmars is offline   Reply With Quote