#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    139
    Rep Power
    10

    How to execute javascript from a bookmark


    In Firefox, if you put "alert('what is up');" as a path to a bookmark, then that js will execute when you "go to" that bookmark. But how do you do this in other browsers? I doesn't work in IE. I honestly haven't checked the others. But if you have, and it's not the same as above, could you please share your wisdom?
    Thanks,
    Dan

    Operating system ubuntu 12.04
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,127
    Rep Power
    4304
    They're called "bookmarklets" and they work fine for me in FF, IE, and other browsers.

    However, I'm surprised that this would work:
    Code:
    alert('what is up');
    Usually you need to use the "javascript:" pseudo-protocol:
    Code:
    javascript:alert('what is up');
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    139
    Rep Power
    10
    Yup. Forgot the "javascript:" I didn't realize there is a name for this, bookmarklets. Funny, I thought I was pretty clever using it. I see here I'm only about 15 years late on the bandwagon
    http://www.bookmarklets.com/tools/data/index.phtml

    Thanks Kravvitz
    Thanks,
    Dan

    Operating system ubuntu 12.04

IMN logo majestic logo threadwatch logo seochat tools logo