[Greasemonkey] Adding an onsubmit

WHITEMARE2 whitemare2 at delphiforums.com
Sun Jan 8 15:05:58 EST 2006


I replaced a rich text editor on a site using a script.  Everything is working okay, except I need to add some code when the form is submitted.  The form already has an onsubmit event defined for form _pttmf on the original page.  I tried this code, but the newsubmit function is not called when I click the submit button.  What am I doing wrong?

function newsubmit(event) { 
    alert('newsubmit');
}

document.getElementById('_pttmf').addEventListener('submit', function(e) {
     // stop the event before it gets to the element and causes onsubmit to
     // get called.
	e.stopPropagation( );

	// stop the form from submitting
	e.preventDefault( );

	newsubmit(e);
        }, true);




More information about the Greasemonkey mailing list