[Greasemonkey] halting navigation via Javascript

chris feldmann cfeldmann at gmail.com
Wed Oct 5 21:16:18 EDT 2005


On 10/5/05, Lenny Domnitser <ldrhcp at gmail.com> wrote:
> On 10/5/05, chris feldmann <cfeldmann at gmail.com> wrote:
> > tiddles? This esoteric jargon is beyond me! BUT, you could iterate
> > through the page with an xpath query and add an event listener to all
> > the anchor elements. Then preventDefault() and have your way with
> > them. Maybe add a confirm()?
>
> It's a one-liner. No need for a confirm()--this automatically prompts
> the user whether they really want to stay on the current page:
>
> addEventListener('beforeunload', function(e) { e.preventDefault(); }, false);

Yeah I noticed that on the bugzilla page Edward posted. Interesting
that one poster even argued that that was a reason not to support the
event in mozilla: dialog creep. I won't mention how long my proof of
concept script got before I posted this, but it was more than one line
:-(


> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>


More information about the Greasemonkey mailing list