open pop up after clicking bookmark link

随声附和 提交于 2020-01-06 17:58:53

问题


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.


回答1:


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/



来源:https://stackoverflow.com/questions/8383917/open-pop-up-after-clicking-bookmark-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!