Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the best-selling Take Control ebooks.

 

 

Pick an apple! 
 
Show Recent Items in Snow Leopard

The Recent Items submenu in the Apple menu is handy, but what if you want to work with a file in there in the Finder, rather than open it? Just press Command when that menu is showing, and all the Applications and Documents change to "Show ... in Finder." This feature is new as of Mac OS X 10.6.3 Snow Leopard.

Visit Take Control of Exploring & Customizing Snow Leopard

 
 

Hyperspatial JavaScript Search Bypass

Send Article to a Friend

If you're at all like me, searching is one of the main things you do on the Web. Perhaps you're searching in Google, looking up a word at Dictionary.com, or just trying to find that TidBITS article you read a few weeks ago. Let me see if I can guess how you go about searching. First, you launch or switch over to your Web browser. Then you choose a bookmark, click a toolbar button, or just type the name of the site in the browser's address bar. After the page loads, you scan the page to locate the Search field, click in it, type your search phrase, and press Return. Phew! What a lot of work, just to perform a simple search! For some Web sites, though, you can bypass much of that effort.

(As a brief aside, to make sure you aren't wasting as much time as Windows users do, note that if you want to visit a Web site like www.apple.com, you can just type "apple" - minus the quotes - in the address bar and press Return. All Mac Web browsers can fill in the "www." and the ".com" for you, although you may have set recent versions of Netscape and Mozilla to ignore Netscape's annoying Smart Browsing feature by disabling the Internet Keywords option in Netscape's preferences). It's a great timesaving trick.)

The unnecessary parts of the standard approach to searching are visiting the home page of the site you want to search, waiting for it to load, and then finding and entering the Search field. Instead, you can embed an extremely simple JavaScript script in a bookmark, that, when clicked, pops up a search dialog and sends what you type in that dialog directly to the site's search engine, showing you just the results page.

In case you're starting to worry that this will require programming or get complicated, don't worry. I know absolutely no JavaScript either, and if you can edit a bookmark, you can use this script. I can't take credit for creating the script, either; I found it on the Web years ago, perhaps among the tools Google provides for simplifying searching. I merely figured out how to modify the script for my purposes, and that's what I'm going to show you.

Search Me -- Here then is the script that I use to search TidBITS directly. As you can see, there's almost nothing to it, and there are only two parts you need to understand.

javascript:void(q=prompt('Enter text to search for in TidBITS.',''));
if(q)void(location.href='http://db.tidbits.com/getbits.acgi?tbtxt='+escape(q))

First, in the parentheses after the word "prompt" is the text that will appear in the dialog that pops up after you click the script's bookmark. Enter anything you want there, but if your Web browser doesn't honor the spaces between words, replace them with %20. (I thought the %20 replacements for spaces used to be necessary, but they don't seem to be now.)

Next, look at the URL. As you can see, it ends somewhat abruptly after the equals sign. That's because the script appends the text you type in the dialog to the end of the URL, right after the equals sign. So, if you want to modify the script to work with a different Web site, you need to find a URL into which a search term can be inserted. With some sites, like Dictionary.com, that's easy, since they display a readable URL that includes your search term in the address field after you search. In other cases, like Google, you may have to play with the URL a bit, deleting unnecessary parts and testing to make sure the URL still works. The URLs of many Web sites contain additional session or tracking information that's not strictly necessary. There are also Web sites like ours, where you're unlikely to guess the proper format for a search URL unless someone tells you. Lastly, for some sites, like Amazon, it may not be possible to start a search with a special URL.

There's no need for you to put effort into creating these scripts for Google or Dictionary.com, since I've already done so.

javascript:void(q=prompt('Enter text to search using Google.',''));
if(q)void(location.href='http://www.google.com/search?q='+escape(q))
javascript:void(q=prompt('Enter word to look up.',''));
if(q)void(location.href='http://dictionary.reference.com/search?q='+escape(q))

Enhancing Your Browser -- Now you have three scripts you can use to search TidBITS, Google, and Dictionary.com, and you have the basics you need to modify these scripts for other sites that will perform a search after being given a properly formatted URL. How do you build these scripts into your browser?

It's simple, although the process is different for every browser. Just create a bookmark or favorite, edit it, give it a descriptive name, and where the bookmark's URL normally goes, paste one of the scripts above. Although it may not matter in your particular browser, it's safest to make sure the entire script is all on a single line before pasting it into the bookmark's URL field. Some Web browsers don't accept Return characters in pasted URLs.

Since I do so much searching, I like to put the script's bookmark in the Web browser's toolbar. That's usually just a matter of making sure it's in the appropriate folder in the Bookmarks or Favorites window. Then, when I want to search, I switch to my browser, click the appropriate bookmark and type the words I want to find. No more visiting the site's home page just to find a Search field, and no more hunting down an obscured Search field.

For whatever reason, I'm not bothered by having to switch to my Web browser before performing the search. I suspect that's because my first subconscious thought is that I have to search on the Web, and only secondarily do I think about what site to search. However, if you use Internet Explorer (and possibly other browsers, though this trick did not work with the Chimera, Mozilla, and Netscape cousins), you can also drag the script bookmark from the Favorites window to your Desktop to create a stand-alone file that you can put it anywhere you want, such as your Apple menu in Mac OS 9 or your Dock in Mac OS X. You can also use the script file with any utility that can open a file, such as QuicKeys, DragThing, or the like. (Since many utilities can open URLs directly, you might think you could just paste the script into them directly, but in my experience, most don't know what to do with a JavaScript script instead of a plain URL.)

Searching Far and Wide -- There are undoubtedly many other techniques and utilities for speeding the process of searching various Web sites. I've tried a number of searching utilities over the years, including Apple's Sherlock, but none have ever quite grabbed me. It always felt as though they were adding another layer of effort to the task rather than simplifying it. However, if you have a technique you're particularly proud of, submit it to TidBITS Talk at <tidbits-talk@tidbits.com>, and if there are enough interesting submissions, I'll collect them and put together another article.

PayBITS: If this technique changes how you search, why not drop
Adam a few bucks via Amazon's Honor System. No account needed!
<http://www.amazon.com/paypage/P36I264HFO9H4A>
Read more about PayBITS: <http://www.tidbits.com/paybits/>

 

Updated! PDFpen for iPad 1.7: Designed for iOS 7, faster, and
better-looking. Edit your PDFs anywhere. Sign contracts, make
changes, fill forms, and more. All while you’re on the move.
Syncs via iCloud and Dropbox. <http://smle.us/tbpdfpen-ipad>