views:

68

answers:

1

Essentially I'm trying to

  1. navigate to a webpage
  2. wait for that webpage to load
  3. execute a JS function/alert/whatever on that page

all from a single bookmarklet. Is this possible? I can't seem to get onload to work for me, but that may be because of my own personal failings here.

A: 

You want to install the Greasemonkey extension for Firefox. (or gm4ie for IE, or greasemetal for Chrome (PersonalizedWeb also works in a much simpler way for Chrome), greasekit for Safari, or user.js for Opera)

Greasemonkey lets you do exactly this... run a script automatically on every page load (you can choose what pages/sites it loads on)

Otherwise you will need to click your bookmarklet on every page load in order to run your script.

scunliffe
So Greasemonkey (or its equivalent in $browser) is the only solution for this? My goal was to just make a bookmarklet I could share with other people, instead of requiring an add-on in each case.For some context, the problem I'm tryign to work around is my school's website. The web designers thought it would be a brilliant idea to make all links on the site merely JS links which through some cryptic combination of PHP and AJAX update the webpage. Unfortunately, because of the way they did this it's currently impossible to link to, say, your classes' homework page.
scikidus
Instead you have to say "Go to website, then click here, then click here, then click here." My hope was to make a bookmarklet which would load the website and once the page loaded run the JS links necessary to retrieve the desired page.
scikidus
Ah,@scikidus I see... well unfortunately it sounds like the site is out of your control. You could create/use a bookmarklet, but there is no way to trigger it to run automatically (without) resorting to a Greasemonkey-type solution. Is there a chance you can talk with the staff at your school to offer up a fix for the site? As for the original developers (-1 for JS-only links)
scunliffe