问题
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