"Simon" <si****************@btinternet.please.com> wrote in message
news:c1**********@titan.btinternet.com...
With your webbrowser parked at your preferred google page, type this in the addressbar:
javascript:function x(){p=prompt('Your name...');alert('Welcome to
Google, '+p) }; void(x());
and hit return. You won't leave the page (if you didn't make a typing
mistake).
As you can see, you have just added a function called x to the current
page. It 's the type of scripting upon which bookmarklets are based.
Thanks for that - looks useful. I want to make the process automatic (i.e.
without typing in the address bar) - any ideas? I guess I can probably
hook the address bar and update it but I'd rather use a neater method if you
know of one?
Simon
I got a present for you, Simon. Like a proper present, you need to carefully
unwrap it, that is copy and paste each of the following lines in your
address bar, one after another, without spaces or other noise in between
(meanwhile, look at the code and guess what is going to happen), so that it
becomes one line again:
javascript
:void((function(){var s='';(function(w){for(var
i=0;i<w.length;i++){arguments.callee(w.frames[i]);}try{s+=w.document.selecti
on.createRange().text;}catch(e){try{s+=w.document. getSelection();}catch(e){a
lert('Bookmarklet failed:\n\n'+e.message);}}})(top);if(!s)s=prompt(' Enter
keywords:','');if(s)location='http://www.google.com/search?q='+escape(s);})(
))
If you 're confident all is well, hit return and if you haven't selected any
text on the current page, you will be prompted for a search query. You can
save this javascript code in your Favorites, on your Personal Toolbar even,
if you write it in an <a href="javascript
:..." tag and bookmark that link.
There are other, more convenient ways but there re not all easy to explain
unless bookmarklets tickle your imagination.
Also see:
http://www.bookmarklets.com/tools/search/ introduces you to dozens of
bookmarklets, specifically engineered for faster searching.
http://www.bookmarklets.com/mk.phtml even has a bookmarklet to helps you in
creating bookmarklets for any search engines not yet listed.
HTH
Ivo