Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > google search site bookmarklet

Reply
Thread Tools

google search site bookmarklet

 
 
gwtc
Guest
Posts: n/a
 
      07-02-2006
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:

javascriptfunction(){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.
 
Reply With Quote
 
 
 
 
Ivo
Guest
Posts: n/a
 
      07-02-2006
"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:
>
> javascriptfunction(){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


 
Reply With Quote
 
 
 
 
gwtc
Guest
Posts: n/a
 
      07-02-2006
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:
>>
>>javascriptfunction(){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.
 
Reply With Quote
 
Ivo
Guest
Posts: n/a
 
      07-04-2006
"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:
javascriptfunction(){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


 
Reply With Quote
 
gwtc
Guest
Posts: n/a
 
      07-04-2006
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:
> javascriptfunction(){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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Try Doing A Google Search For Greg Carr On Google Groups Kevin C Baer Computer Support 4 09-16-2008 10:09 PM
Good Website Search Engines Besides Google Search ... Chris K. HTML 3 06-08-2008 05:46 AM
Google search result like site search!! How? =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?= ASP .Net 3 05-06-2005 02:08 AM
Google search & RAX search Gunjani Computer Support 2 02-14-2005 06:54 PM
Firefox google search bar searches google.de Abso Firefox 3 01-06-2005 10:55 PM



Advertisments