I’m having trouble trying to override a form element’s onsubmit event. I have no problem adding a listener with addEventListener, but for my particular case, I need to replace the onsubmit but for some reason when I do, it gives me this error:
Error: Component is not available = NS_ERROR_NOT_AVAILABLE
My code is simply this:
gBrowser.contentDocument.getElementById("theform").onsubmit = function() {
return false;
};
Essentially I want to prevent the form from submitting, but this code fails and throws the above error. Using addEventListener to return false doesn’t seem to stop the form from submitting.
Thanks.
For security reasons, the object returned by
getElementByIdin an extension is anXPCNativeWrapperaround the DOM element; it’s not the element itself. This results in some important limitations. More details here: