Create a link to a web page that runs a Javascript function on the page

别说谁变了你拦得住时间么 提交于 2019-12-24 01:26:02

问题


Using HTML and Javascript, is it possible to create a link to a web page that automatically runs a specific Javascript function on the web page (e. g., a bookmarklet)? I have a bookmarklet that highlights all matches of a regular expression, and I want to create a hyperlink to http://en.wikipedia.org that automatically runs the bookmarklet on http://en.wikipedia.org.


回答1:


You could use something like GreaseMonkey or something equivalent for the browser your on.




回答2:


This is pretty much the textbook definition of cross site scripting, so no, generally that is not something you can do. The user must run the bookmarklet. What you can look into is making an addon or extension for browsers.



来源:https://stackoverflow.com/questions/13294483/create-a-link-to-a-web-page-that-runs-a-javascript-function-on-the-page

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