Situation:
-- VB.NET Windows app with embedded Browser control
-- Browser control loads form-based text entry web app (not ours, I
have no control over the HTML or the script that comes up)
-- Pages of web app contain field validation via JavaScript
-- Validation throws alert()'s to indicate failed validation
conditions
How can the WinForms app intercept those alerts? Since the app I'm
writing is all about auto-populating the external form with our data,
I need to handle the conditions that arise when our data does not pass
the validation functions. Ultimately, I'd like to record the text of
the alert, but can't figure out how.
I've gone down the following paths without success:
-- Try to find an event on the Browser control that would tell me
anything (nope)
-- Try to find an event on the mshtml.HTMLDocument object that would
tell me something (nope)
-- Find a way to inject a new script function (myalert) into the DOM
that would do the normal alert and raise a browser event, and try
iterating through the mshtml.HTMLDocument.scripts collection,
replacing each alert('xyz') with myalert('xyz'). Several problems
with that approach...having trouble injecting the new function, don't
know what browser event to raise that I could handle externally, the
scripts that the pages use are external (<script src="blah.js"/>).
Anyone have any ideas?
Could I go lower than this and try to handle window creations for the
alert windows? I haven't a clue whether this is even possible, let
alone how to tackle it.
Vadim Melnik - 01 Sep 2003 14:53 GMT
Hi,
> Situation:
> -- VB.NET Windows app with embedded Browser control
[quoted text clipped - 5 lines]
>
> How can the WinForms app intercept those alerts?
See IDocHostShowUI::ShowMessage.
WebBrowser Customization -
http://msdn.microsoft.com/workshop/browser/hosting/wbcustomization.asp
Google -
http://groups.google.com/groups?hl=uk&lr=&ie=UTF-8&oe=UTF-8&threadm=0tqKRwteCHA.
2280%40cpmsftngxa08&rnum=3&prev=/groups%3Fhl%3Duk%26lr%3D%26ie%3DUTF-8%26oe%3DUT
F-8%26q%3Dalert%2BIDocHostShowUI
..
Regards,
Vadim.