BeforeEvent.submit not working on javascript form submit?

Forums » Dev.Opera » Opera Extensions Development Discussions

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

19. September 2012, 21:23:55

Phen1x

Posts: 10

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 smile

20. September 2012, 23:33:07

spadija

Posts: 1635

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.

Forums » Dev.Opera » Opera Extensions Development Discussions