Browser Helper Object : How to stop form being submitted
-
:cool:Hi, I have created Browser Helper Object(BHO) to get and handle events triggered by "Internet Explorer"(IE). I am albe to intercept events of IE like DocumentComplete etc. Even I am getting the submit event of the form when "submit" button is clicked. But I am not been able to stop the form being submitted. May be because of when I get the submit event of the form meanwhile somebody other who is responsible for submitting the form is submitting it.(by using POST or GET method, may be browser itself is submitting the form) Now the problem is by intercepting which event of whom i.e. of IWebBrowser2 or HTMLFormElements or any other Interface can I stop the submition of form. I actually want to know which event is triggered, that can be caught in IDispatch::Invoke of my BHO, when form(html form) is sent to server(by POST or GET method). Avinash D.J.
-
:cool:Hi, I have created Browser Helper Object(BHO) to get and handle events triggered by "Internet Explorer"(IE). I am albe to intercept events of IE like DocumentComplete etc. Even I am getting the submit event of the form when "submit" button is clicked. But I am not been able to stop the form being submitted. May be because of when I get the submit event of the form meanwhile somebody other who is responsible for submitting the form is submitting it.(by using POST or GET method, may be browser itself is submitting the form) Now the problem is by intercepting which event of whom i.e. of IWebBrowser2 or HTMLFormElements or any other Interface can I stop the submition of form. I actually want to know which event is triggered, that can be caught in IDispatch::Invoke of my BHO, when form(html form) is sent to server(by POST or GET method). Avinash D.J.
You can't stop the form from being submitted. You are responding to a notification that the form *has* been submitted.
Have you answered an MTQ? Check out the stats!
What's the latest butt-scratch count? Check it out! -
:cool:Hi, I have created Browser Helper Object(BHO) to get and handle events triggered by "Internet Explorer"(IE). I am albe to intercept events of IE like DocumentComplete etc. Even I am getting the submit event of the form when "submit" button is clicked. But I am not been able to stop the form being submitted. May be because of when I get the submit event of the form meanwhile somebody other who is responsible for submitting the form is submitting it.(by using POST or GET method, may be browser itself is submitting the form) Now the problem is by intercepting which event of whom i.e. of IWebBrowser2 or HTMLFormElements or any other Interface can I stop the submition of form. I actually want to know which event is triggered, that can be caught in IDispatch::Invoke of my BHO, when form(html form) is sent to server(by POST or GET method). Avinash D.J.
As Terry has already pointed out, an event signalizes in this case that something has already taken place, and you cannot influence the trigger of the event in the past. However there is a workaround, and it is called API hooking/hijacking/monitoring. Internet Explorer uses the Wininet functions to communicate with the internet. If your user clickes the "go" button with some url in the address bar, the appropriate Wininet functions, like HttpOpenRequest and HttpSendRequest are called inside IE's code. The same applies to when the user submit a form. If you hook into the WinInet functions from your BHO, then you will be able to monitor and "authorize" IE's actions. Example: if your user clicked a Submit button on a form with POST action then HttpOpenRequest is called with the second parameter lpszVerb being "POST". You can take any action including stopping the process. If a form with "GET" action is concerned, your job is a bit more difficult because the verb in this case does not differ from "ordinary" page requests. You could then take into account the url from your form, and compare it with lpszObjName (3. param of HttpOpenRequest) If you are unfamiliar with API hooking, check out this article: http://www.codeproject.com/useritems/api_monitoring_unleashed.asp Peter Molnar