开发者

How to execute javascript using the mshtml

开发者 https://www.devze.com 2023-02-28 07:12 出处:网络
mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass)IE.Document; object script= doc.Script; object[] args = { FirstArgument , \"FrameContent\", \"tree.aspx\", \"FrameNav\" };
mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass)IE.Document;
object script= doc.Script;
object[] args = { FirstArgument , "FrameContent", "tree.aspx", "FrameNav" };
script.GetType().InvokeMember("ZweiFrames", 
                              System.Reflection.BindingFlags.InvokeMethod, 
                              null, script,args);
Marshal.ReleaseComObject(script);

I used the above code to execute java script and getting an error.(Exception has been thrown by the target of an invocation) ( inner Exception : Insufficient memory to continue the execution of the开发者_开发百科 program).

Please help me on this..

Thanks in advance.. Unni.


Have you checked ZweiFrames js function - may be there is issue in that function with arguments supplied by you?

BTW, yet another way to execute javascript function can be something like

HTMLWindow2 iHtmlWindow2 = (HTMLWindow2) doc.Script ;
iHtmlWindow2.execScript( "functionName(param1);" , "javascript" );

This is of course assuming that your parameters can be represented in a string form.

0

精彩评论

暂无评论...
验证码 换一张
取 消