Read Javascript Messagebox content from webclient

M

Michael Duclon

Does anyone know how I might use the webclient class to navigate to a web
page in a vb.net app, and then if a JavaScript popup appears from the web
page I go to, read the message in it or content of it, then close it so I
can continue on.
I don't know how to reference the popup box or send a command to click the
ok button to close it.
Mike Duclon
 
M

Martin Honnen

Michael said:
Does anyone know how I might use the webclient class to navigate to a web
page in a vb.net app, and then if a JavaScript popup appears from the web
page I go to, read the message in it or content of it, then close it so I
can continue on.
I don't know how to reference the popup box or send a command to click the
ok button to close it.

WebClient does a HTTP request and fetches the HTTP response for you but
it does not know anything about HTML documents or HTML documents with
JavaScript.
If you want to render a HTML document like a browser does then in .NET
2.0 you have the WebBrowser control
<http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx>
I am not sure however there is a way then from .NET to close JavaScript
alert dialogs.
 
J

John Timney \(MVP\)

When you request the page using the webclient classes, the remote server
sends the page back as a response. It does not undertsand html or
javascript and will not actually run the page for you as a browser would, in
short you have the resulting HTML as if you did a view source from within a
browser..

Regards

John Timney (MVP)
 
M

Michael Duclon

thanks Martin, I've decided to try and use the WebBrowser control.
I'm looking at it to see if I can figure out how to close the javascript
window using that route. It seems like I should be able to access it from
the document object.
If anyone has any thoughts on that or has tried this please let me know, and
if I find the answer I will post back.

Michael Duclon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top