Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2003

Tip: Looking for answers? Try searching our database.

Handling Browser control's Alert()'s

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fryguy - 29 Aug 2003 20:01 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.