The Code
First, the JavaScript. This bit of code will open a new browser
window and plug the highlighted text into a URL. This code needs to
be in a file somewhere on your computer where it can be accessed from
the browser, and won't be deleted in a fit of spring cleaning. You
could even create a new folder for it,
c:\scripts\. If you have another location in
mind, be sure to change any references to
c:\scripts\ in the following code.
Create a file
called
AmazonSearch.html and add this code:
<script language="JavaScript">
var searchURL = new String("http://www.amazon.com/exec/obidos/[RETURN]
external-search/mode=blended&keyword=");
var w = window.external.menuArguments;
var d = w.document;
var s = d.selection;
var r = s.createRange( );
var term = new String(r.text);
window.open(searchURL + term);
</script>
Save it in the c:\scripts\ directory.
Next you need to add some information to your Windows registry to let
Internet Explorer know where to find
AmazonSearch.html, and when exactly it should be
executed. You could open up a registry editor
and add values manually, but it's just as easy to put the information
into a .reg file and add it by double-clicking.
Create a new file called AmazonContext.reg and
add the following code:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\[RETURN]
Search Amazon]
@="c:\\scripts\\AmazonSearch.html"
"contexts"=dword:00000010
TIP
Backslashes, like those in filesystem paths, need to be escaped as
double-slashes (\\) in registry entry files.
Save the file on your desktop, double-click it, and confirm that you
want to add the new registry information. This setting adds a
right-click menu entry called "Search Amazon" that will appear
whenever text is highlighted. It also points to the JavaScript file
and will execute it when the highlighted entry is clicked.
When I highlight a term, I get the option to do a Google Search. It opens the search in a new window. And underneath that there's "[RETURN."
Any idea why this is happening? Could it have something to do with the Google toolbar?