第一篇,winform窗体嵌套在html页面中,使用js调用
2012-09-23 21:39 sara的小窝 阅读(3264) 评论(0) 收藏 举报js代码:
function openwin(name) {
    document.getElementById('testwin').innerHTML = window.external.test();
}
C#代码:
winform中,首先 加入 [System.Runtime.InteropServices.ComVisibleAttribute(true)]
    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    [System.Runtime.InteropServices.ComVisibleAttribute(true)]
    public partial class Win : Form
    {
      private void Win_Load(object sender, EventArgs e)
        {
           this.browser.ObjectForScripting = this;
        }
public string test() { return "test"; }//被js调用的公共方法
}
 
                    
                     
                    
                 
                    
                 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号