Search code examples
javascriptbookmarklet

open pop up after clicking bookmark link


I am working on a short application. In which I have followiing things.

  1. move a link something from my page to Bookmark Toolbar of Browser- Done.
  2. After clicking on the bookmark link pop should open. (user can be at any other website). he will click on the bookmark link and then pop up should open -- NOT DONE
  3. that pop should fetch the title,meta,description of parent window (users current opened website).--DONE

Obviously My question is about 2 Point. I cant figure out how to make this bookmark link to an absolute css/javascript so that it can open on any website.


Solution

  • You can add javascript to URLs like so:

    <a href="javascript:alert('hello');">Bookmarklet</a>
    

    Note that I have prepended the URL with javascript: to indicate the browser that it should execute the URL as javascript.

    So for a pop it would be something like:

    <a href="javascript:window.open('http://www.example.org');">Bookmarklet</a>
    

    Here is a jsFiddle with the code above for you to test.

    For more information about bookmarklets you might like the following article: http://betterexplained.com/articles/how-to-make-a-bookmarklet-for-your-web-application/