Winfrom中我拉了一个控件webBrowser1,我想在其他线程中执行 js函数f_SaveInfo,出现异常"指定的转换无效" 15
//C#后台代码publicFrmSession(){InitializeComponent();stringurl=System.IO.Path.GetFullPath...
//C#后台代码
public FrmSession() { InitializeComponent(); string url = System.IO.Path.GetFullPath("../../XX.html"); webBrowser1.Url = new Uri(url); webBrowser1.ObjectForScripting = this;
Thread TempThread2 = new Thread(new ThreadStart(this.reception)); TempThread2.Start(); } public void reception() { while (true) { System.Threading.Thread.Sleep(3000); AppInfo("为什么不行"); } } public void AppInfo(string info) { webBrowser1.Document.InvokeScript("SaveInfo", new Object[] {string.Format("{0:HH:mm ss}", DateTime.Now), info }); }
//JS函数
function SaveInfo(InfoTime, InfomMagess) { alertInfomMagess(); }
//提示的错误
JS函数中写错了,但不是引起错误的问题
alert(InfomMagess); 展开
public FrmSession() { InitializeComponent(); string url = System.IO.Path.GetFullPath("../../XX.html"); webBrowser1.Url = new Uri(url); webBrowser1.ObjectForScripting = this;
Thread TempThread2 = new Thread(new ThreadStart(this.reception)); TempThread2.Start(); } public void reception() { while (true) { System.Threading.Thread.Sleep(3000); AppInfo("为什么不行"); } } public void AppInfo(string info) { webBrowser1.Document.InvokeScript("SaveInfo", new Object[] {string.Format("{0:HH:mm ss}", DateTime.Now), info }); }
//JS函数
function SaveInfo(InfoTime, InfomMagess) { alertInfomMagess(); }
//提示的错误
JS函数中写错了,但不是引起错误的问题
alert(InfomMagess); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询