Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DOM - insert java script and execute

0 views
Skip to first unread message

IP

unread,
Oct 18, 2005, 5:40:48 AM10/18/05
to
Hi All

I have a web-browser object and the corresponding DOM tree as below (C#
code):
htmlDoc=(HTMLDocument)wb.Document;

IHTMLDOMNode domNode;

domNode=(IHTMLDOMNode)htmlDoc.documentElement;

I want to be able to insert a JavaScript into this DOM tree and then execute
it. This script will fill up the form with some values and submit it.

Can anyone please help me with a code sample for the above.

Any help is much appreciated.

Thanks & regards,

NG


IP

unread,
Oct 19, 2005, 4:46:42 AM10/19/05
to
Hi All
I am able to do this using following statement:

doc.parentWindow.execScript("var aForm =
document.getElementById('LoginForm'); aForm.submit();", "JavaScript");

However I have one problem if I dont use the Web Browser and directly use
the following code without the web browser:

THIS IS VB.NET CODE ENCAPSULATED INTO A CLASS LIBRARY THAT RETURNS THE
DOCUMENT OBJECT

Dim objMSHTML As mshtml.HTMLDocument

Dim objDocument As mshtml.IHTMLDocument2

Dim ips As IPersistStreamInit

objMSHTML = New mshtml.HTMLDocument

ips = DirectCast(objMSHTML, IPersistStreamInit)

ips.InitNew()

objDocument = objMSHTML.createDocumentFromUrl(strURL, String.Empty)

THIS IS C# CODE THAT USES THE DOC OBJECT RETURNED BY VB.NET ABOVE

objDocument .parentWindow.execScript("var aForm =
document.getElementById('LoginForm'); aForm.submit();", "JavaScript");

Now after this point, I want to access the HTML related to the response. I
tried objDocument .outerHTML but that still contains the old HTML. How to
get the HTML of the login response.

PLEASE HELP.....

Thanks,

NG

<IP> wrote in message news:epGndg80...@tk2msftngp13.phx.gbl...

0 new messages