Skip to content

Instantly share code, notes, and snippets.

@chrisle
Created February 11, 2013 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisle/4757219 to your computer and use it in GitHub Desktop.
Save chrisle/4757219 to your computer and use it in GitHub Desktop.
Nicos bookmarklet
// This is to be used as a bookmarklet
// Supposed to show a prompt where you pick if you want to do a site: search alpha using 'a' or bravo using 'b'
// However, this isn't working as a bookmarklet but does work in the live w3 editor
javascript:var name=prompt("Please enter your name \n a = alpha \n b = bravo","x");
switch (name) {
case "a":
location.href='http://www.google.com/search?q=site%3A'+document.domain.replace('www.','')+" alpha"
break;
case "b":
location.href='http://www.google.com/search?q=site%3A'+document.domain.replace('www.','')+" bravo"
break;
default:
location.href='http://www.google.com/search?q=site%3A'+document.domain.replace('www.','')+" ";
}
// Fixed. You forgot semicolons at the end of the statements. If you checked the inspector window, you would have seen that as an error.
javascript:var name=prompt("Please enter your name \n a = alpha \n b = bravo","x");
switch (name) {
case "a":
location.href='http://www.google.com/search?q=site%3A'+document.domain.replace('www.','')+" alpha";
break;
case "b":
location.href='http://www.google.com/search?q=site%3A'+document.domain.replace('www.','')+" bravo";
break;
default:
location.href='http://www.google.com/search?q=site%3A'+document.domain.replace('www.','')+" ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment