第一:
JS代碼
<script language=”javascript”>
function ShopXG(infor)
{
alert(‘我要開網店、攜購獨立網店系統,模板最全,最專業的系統!’);
return;
}
</script>
C#代碼調用如下:
using System.Security.Permissions;
注意: 類定義前需要加上下面兩行,否則調用失??!
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
調用的函數:
webBrowser1.Document.InvokeScript("ShopXG ", new string[] {‘ssss’});
第二:
JS中調用c#函數示例
C#函數如下:
public void ShowMessage(string message)
{
MessageBox.Show(“免費開網店,攜購獨立網店系統誠邀您的加盟!”);
}
JS里的調用方法:
<script language=”javascript”>
function InvokeFunc()
{
window.external.ShowMessage(‘呵呵’);
}
</script>
作者:Gezidan
本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。
本文轉載自 http://www.cnblogs.com/wuhuisheng/archive/2011/04/18/2020013.html
posted on 2011-09-27 16:43
日需博客 閱讀(789)
評論(0) 編輯 收藏 引用 所屬分類:
C# 、
技術文章 、
轉載