By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

google search site bookmarklet

P: n/a
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('S earch \''+h+'\'
using Google:',q);if(q!=null){if(h){q='site:'+h+'
'+q;}location='http://www.google.com/search?q='+encodeURIComponent(q);}})();

--
Murphy's Laws of Computing: The number one cause of computer problems
is computer solutions.
Jul 2 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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('S earch \''+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
Jul 2 '06 #2

P: n/a
Ivo wrote:
"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('S earch \''+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

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

--
Murphy's Laws of Computing: The number one cause of computer problems
is computer solutions.
Jul 2 '06 #3

P: n/a
Ivo
"gwtc" schreef
Ivo wrote:
>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'.
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('S earch \''+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
Jul 4 '06 #4

P: n/a
Ivo wrote:
"gwtc" schreef
>>Ivo wrote:
>>>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'.

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('S earch \''+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.

--
Murphy's Laws of Computing: A complex system that does not work is
invariably found to have evolved from a simpler system that worked
just fine.
Jul 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.