Html_Js_Function Load Form_Function & Form_Function Load Html_Js_Function

 Html Run Form:

 

[System.Runtime.InteropServices.ComVisible(true)]  //Open ComVisible

 

//Create Html Page

 

            this.webBrowser1.ObjectForScripting = this; //Get  Form_Window Obj

            this.webBrowser1.Navigate("");

            this.webBrowser1.Document.Write("<html><head>");
            this.webBrowser1.Document.Write("<script type='text/javascript'>");
            this.webBrowser1.Document.Write("function HtmlJs(){window.document.getElementById('b1').innerHTML+='执行Js脚本,写Html页面'}");
            this.webBrowser1.Document.Write("</script>");
            this.webBrowser1.Document.Write("</head><body id='b1'>");
            this.webBrowser1.Document.Write("<input type=button value='测试'id='bt1' οnclick='javascript:{window.external.test()}'>");// Html_Page  Run  Form_Window Function [test]
            this.webBrowser1.Document.Write("</body></html>");

 

//Form_Window Function

        public void test()  // Public is Must!
        {
            MessageBox.Show("执行窗体函数");
        }

 

 

 

 Form Run Html:

webBrowser1.Document.InvokeScript("HtmlJs");  // Form_Window Run Html_Page JsFunction[HtmlJs]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值