views:

40

answers:

1

I have a bookmarklet which gets current website TITLE and search for it on my website:

javascript:q=(document.location.host);void(open('http://example.com/search.php?search='+document.title,'_self','resizable,location,menubar,toolbar,scrollbars,status'));

But now I would like to change this bookmarklet so it will search for current website title like now and if title is not found it should search for website host. So I guess I should use else option or something???? Is there any way to do this? I wonder what the bookmarklet should be...

Thank you for your help!

A: 

Replace document.title in your code with:

((document.title) ? document.title : document.location.host)
Mark B