我写了一个winform获取到一个网页(WebBrowser控件获取的),网页源码中有以下脚本引用
<script language="javascript" type="text/javascript" src="/js/g.js"></script>
<script language="javascript" type="text/javascript" src="/js/email/validate.js"></script>
<script language="javascript" type="text/javascript" src="/js/comm.js"></script>
<script language="javascript" type="text/javascript" src="/js/e1.js"></script>
现在我想在控制调用其中的一个JS文件中的一个功能函数
请问各位大侠怎么实现

解决方案 »

  1.   

      有个document.invertscript("(函数名就行)");
    可能写法有错误,不过我用过,在我那个电脑里了。差不多就是这样就行
      

  2.   

    脚本我一点都不懂下面这种情况要调用mf_processCountryList是不是不行
    最后还有一个逗号视乎是个函数体结构
    还望指教
        mf_processCountryList: function()
        {
            if(!this.md_bInit || !this.md_loc_xml)
            {
                return;
            };        //var lo_CountryDivObj=$(this.md_countryDivId);
            var lo_CountryDivObj=this.mo_countryObj;
            lo_CountryDivObj.style.display="none";
            Util_List.mf_clear(this.mo_countryObj);
            var lo_Countrys=this.md_loc_xml.getElementsByTagName("CountryRegion");
            
            var ld_text="",ld_value="";
            for(var l_i=0;l_i<lo_Countrys.length;l_i++)
            {
                ld_text=lo_Countrys[l_i].getAttribute("Name");
                ld_value=lo_Countrys[l_i].getAttribute("Code");
                Util_List.mf_add(this.mo_countryObj,ld_text,ld_value);
            };
            lo_CountryDivObj.style.display="inline";
            this.mf_processStateList();
        },
      

  3.   

    “mf_processCountryList: function()”
    这是啥东西脚本我也不咋懂就是看了一点,一位调用谷歌地图API的时候要用到,我定义的函数方法是function mf_processCountryList()
    {
      …………
      …………
    }
    这样然后winform那边就document.invertscript("mf_processCountryList");
    这样用的
      

  4.   

    mshtml.IHTMLDocument2 currentDoc = (mshtml.IHTMLDocument2) webBrowser1.Document.DomDocument;
    mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)currentDoc.parentWindow;
    win.execScript("A()", "javascript");webBrowser1.Document.InvokeScript("A",
      new String[] { "" });
      

  5.   

    这个办法是不是WINFORM中不行?提示错误 找不到我程序webBrowser中的页面
    异常来自 HRESULT:0x80020101
      

  6.   

    问题补充
    因为有两个下拉列表用于输入日期
    一个输入月一个输入日
    输入日之前用脚本判断有没有输入月,然后才允许输入日
    现在问题是要程序填入月和日没办法实现  
    强调用elem.SetAttribute("selectedIndex","5");方法可以修改日中的值但是脚本却知道是软件输入的没有允许日的输入
    我是想想让脚本执行好允许输入日期值
    不知道各位大侠有没有办法帮到我  别的方法也行
      

  7.   

    我理解的就是把WINFORM里的日期控件的值作为参数传到你的JS函数里对吗???
      

  8.   

    http://emailreg.qq.com/cgi-bin/signup/step1?regtype=0
    我也不清楚是不是WINFROM控件  但是它的确控制了月和日之间的关系
      

  9.   

    我用软件修改了月的值
    elem1.SetAttribute("selected", "true");
    但是日的值却没有更新  也没办法选择
    应该是被脚本控制了  
    不知道怎么解决
      

  10.   

    //加载页面  
     private void Form1_Load(object sender, EventArgs e)
            {
                Uri objUri = new Uri(@"D:\Ext Design修改\Ext Designer\designer.html");
                this.webBrowser1.Url =objUri;
            }
           //获取 页面内某一控件的值
            private void button1_Click(object sender, EventArgs e)
            {            string aa = webBrowser1.Document.GetElementById("textarea-viewjson-value").InnerText;            if (null == webBrowser1.Document.GetElementById("textarea-viewjson-value"))
                {
                    MessageBox.Show("null");
                }
                else
                {
                    MessageBox.Show(webBrowser1.Document.GetElementById("textarea-viewjson-value").InnerText);
                }
            }
          //调用某一控件的值
            private void button2_Click(object sender, EventArgs e)
            {           //给某一控件赋值
                webBrowser1.Document.GetElementById("hideeS").InnerText = "D:\\Ext Design修改\\Ext Designer\\deploy\\test.txt";           //调用某一控件的值
                webBrowser1.Document.GetElementById("9iExt").InvokeMember("click"); 
            }
      

  11.   

    异常来自 HRESULT:0x80020101
    这个有可能是调用方法没有找到写script方法的页面,或者是没找到页面上的元素