You need to be logged in to post in the forums. If you do not have an account, please sign up first.
BeforeEvent.submit not working on javascript form submit?
Hey,i am trying to catch the 'submit' event:
window.opera.addEventListener('BeforeEvent.submit',function(e){
// do something
}
This works properly on most web pages. BUT there are some pages, where this event is not raised/catched.
Example:
<html>
<head>
<title>Test</title>
</head>
<body>
<script>
function mySubmit() {
document.getElementById('testForm').submit();
}
</script>
<form id="testForm">
<input type="text" name="test1"/>
<input type="text" name="test2"/>
<a title="Submit" href="javascript:mySubmit();">Submit</a>
// <input type="button" onclick="javascript:mySubmit();"/>
// <input type="submit" onclick="javascript:mySubmit();"/>
</form>
</body>
</html>
In this example, the 'BeforeEvent.submit' is never executed. If you replace the link by
<input type="button" onclick="javascript:mySubmit();"/>it does not work either.
With
<input type="submit" onclick="javascript:mySubmit();"/>it works fine.
Is there a workaround for this?
Thanks for your help
Apparently the submit event only fires when a <input type=submit> element is clicked but not when a form's submit method is called. This post has a solution which may work.
Opera 12.15 - Win 8 Pro x64 All my Opera tools -Tab Vault: Save tabs for later -AutoStack: tabs opened from a stack stay there
Forums » Dev.Opera » Opera Extensions Development Discussions