第一篇,winform窗体嵌套在html页面中,使用js调用
2012-09-23 21:39 sara的小窝 阅读(3237) 评论(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调用的公共方法
}