admin管理员组

文章数量:1290191

To execute bookmarklet code the bookmarklet needs to be actioned by the user. Is there any way to have a bookmarklet or indeed any javascript run automatically on page load?

Or is an Add-on the way to go?

Thanks

To execute bookmarklet code the bookmarklet needs to be actioned by the user. Is there any way to have a bookmarklet or indeed any javascript run automatically on page load?

Or is an Add-on the way to go?

Thanks

Share Improve this question asked Jan 25, 2010 at 10:14 Richard HRichard H 39.1k38 gold badges114 silver badges141 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 5

I don't think that it is possible to autorun a bookmarklet on pageload. This could be used very maliciously.

I think a plugin is the best way to go here. If only for personal use, you should check out greasemonkey for Firefox.

GreaseMonkey

Greasemonkey, or Tampermonkey on Chrome allow this.... but they need the script you want to run

for example, if a certain site always puts up some type of an ad overlay and you can find or write a script to kill that, you can enter that source into Tampermonkey and it will run on each page load globally or at whatever site / domain/ wildcard expression you designate

alternatively if you are looking to block certain scripts and want to automate the process, Notscript for chrome will show you each script that ran when you visited a site and allow you to designate which you want to allow on subsequent visits at that site or all sites, very very cool... that way you need not write or find a script to block behaviors you don't like

as previously pointed out, when you do this stuff you are seriously screwing with browser security, so be careful and just don't set up any old script unless you can read them or trust the source....

I think Opera allows you to auto inject js into a library of sites you specificy 'onload' regardless of ownership.

Well, any javascript runs automatically using onload event, if thats what you need?

本文标签: Is there any way to have some javascript (such as a Bookmarklet) autorun on page loadStack Overflow