google search site bookmarklet

G

gwtc

Here is a google search site bookmarklet. This lets you search a
certain website using google. What I want is the same thing, but to
search a certain geocities site. When you use the current
bookmarklet, the search takes you to site:www.geocities.com instead of
the specific site you want to search. Can someone modify this for me,
to search specific geocities sites?

Thanks for your help and btw I'm using Mozilla Suite and Firefox.

The bookmarklet is:

javascript:(function(){var
h,q;h=location.hostname;q=(window.getSelection ? window.getSelection()
: document.getSelection ? document.getSelection() :
document.selection.createRange().text);q=prompt('Search \''+h+'\'
using Google:',q);if(q!=null){if(h){q='site:'+h+'
'+q;}location='http://www.google.com/search?q='+encodeURIComponent(q);}})();
 
I

Ivo

"gwtc" schreef
Here is a google search site bookmarklet. This lets you search a certain
website using google. What I want is the same thing, but to search a
certain geocities site. When you use the current bookmarklet, the search
takes you to site:www.geocities.com instead of the specific site you want
to search. Can someone modify this for me, to search specific geocities
sites?

Thanks for your help and btw I'm using Mozilla Suite and Firefox.

The bookmarklet is:

javascript:(function(){var h,q;h=location.hostname;q=(window.getSelection
? window.getSelection() : document.getSelection ? document.getSelection()
: document.selection.createRange().text);q=prompt('Search \''+h+'\' using
Google:',q);if(q!=null){if(h){q='site:'+h+'
'+q;}location='http://www.google.com/search?q='+encodeURIComponent(q);}})();

I gather you want to add the pathname up to the first '/' slash after the
hostname. In code (mind the wrap):

h==location.hostname + location.pathname.substring( 0,
location.pathname.substring(1).indexOf( '/' )+1 )

That would give you strings like 'www.geocities.com/swaisman' or
'www.geocities.co.jp/goofy_trip'.

hth
ivo
 
I

Ivo

"gwtc" schreef
Thanks ivo, but I'm not javascripted minded. Where do I add those lines?

Find in your code the bit that sais:
h=location.hostname
and add immediately after that:
+ location.pathname.substring( 0,
location.pathname.substring(1).indexOf( '/' )+1 )

So you get:
javascript:(function(){var h,q;h=location.hostname +
location.pathname.substring( 0, location.pathname.substring(1).indexOf(
'/' )+1 );q=(window.getSelection ? window.getSelection() :
document.getSelection ? document.getSelection() :
document.selection.createRange().text);q=prompt('Search \''+h+'\' using
Google:',q);if(q!=null){if(h){q='site:'+h+'
'+q;}location='http://www.google.com/search?q='+encodeURIComponent(q);}})();

Untested, but should work. I 'm not geocities minded.
ivo
 
G

gwtc

Ivo said:
"gwtc" schreef



Find in your code the bit that sais:
h=location.hostname
and add immediately after that:
+ location.pathname.substring( 0,
location.pathname.substring(1).indexOf( '/' )+1 )

So you get:
javascript:(function(){var h,q;h=location.hostname +
location.pathname.substring( 0, location.pathname.substring(1).indexOf(
'/' )+1 );q=(window.getSelection ? window.getSelection() :
document.getSelection ? document.getSelection() :
document.selection.createRange().text);q=prompt('Search \''+h+'\' using
Google:',q);if(q!=null){if(h){q='site:'+h+'
'+q;}location='http://www.google.com/search?q='+encodeURIComponent(q);}})();

Untested, but should work. I 'm not geocities minded.
ivo
bingo. Thanks ivo. It works great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top