用webbrowser打开一个页面。该页面里有两个frame,其中一个frame中的网页包含一个javascript函数。
问,我要如何调用那个函数?

解决方案 »

  1.   

    webbrowser1.document.window.frames(framename).document.execScript(func)try this
      

  2.   

    IHTMLWindow2::execScript Method
    这个里面的确有这个方法
      

  3.   

    .....你查msdn的方法跟我查的方法不一样的,呵呵,我从dhtml中查
      

  4.   

    不过execscript是我经常用的东东,不用查就知道的
      

  5.   

    Private Sub Form_Load()
       WebBrowser1.Navigate ("file:///" & App.Path & "/hello.html")
    End SubPrivate Sub Command1_Click()
      Dim doc As MSHTML.IHTMLDocument2
      Dim win As MSHTML.IHTMLWindow2
      Dim strParam As String, strDynamic As String
      Set doc = WebBrowser1.Document
      Set win = doc.parentWindow
      strParam = "Hello World!"
      Call win.execScript("showMsg('" & strParam & "')", "JScript")
      strParam = "I am a new element"
      Call win.execScript("showMsg('" & strParam & "')", "JScript")
    End Sub
    hello.html
    <html>
    <head>
    <script language = "javascript">
    function showMsg(uName)
    {
    alert(uName);
    }
    </script>
    </head>
    </html>
      

  6.   

    to liuxiaoyi666(MSMVP小猪妹马甲之八卦兔子) 
    呵呵,经验问题,其实我看了你的回复才知道,最近也在熟悉这个接口做填单的,呵呵
      

  7.   

    哈哈,我做web开发的,如果dhtml有什么问题可以问偶的我猜测可能你也不知道execCommand这个方法还有一个是getElementsByTagName("script")
    还有如此的方法去运行的,变化很多