web浏览器InvokeScript [英] WebBrowser InvokeScript

查看:240
本文介绍了web浏览器InvokeScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有正在使用的JavaScript更改了某些设置Webrowser。我想使用这里的例子一>,但不能得到正确的语法



脚本看起来像这样

 < DIV CLASS =DisplayInput><输入类型=电台NAME =显示类型
值=十进制的onclick =setdisplayType('小数');检查=选中>< A
HREF =JavaScript的:setdisplayType('小数');
的onclick =s_objectID =安培; QUOT;的javascript:setdisplayType('小数'); _ 1安培; QUOT ;;返回this.s_oc this.s_oc(E):真的吗?>十进制< / A>< / DIV>



到目前为止,我没有成功。


$ B $尝试了这些b

  this.webBrowser1.InvokeScript(setdisplayType); 
this.webBrowser1.InvokeScript(setdisplayType('十进制'));
this.webBrowser1.InvokeScript(setdisplayType,十进制);


解决方案

不知道做什么用你的应用程序的错误,也不会发生知道什么 setdisplayType 的样子,我猜,也许你想调用函数 setdisplayType 之前,它一直加载。每MSDN文档...




InvokeScript(字符串,对象())不应该在
文件之前调用实现它已完成加载。您可以检测当
A文件已被处理的 LoadCompleted 事件装载完毕。




也许你可以实现 LoadCompleted 事件处理程序,然后调用你的脚本。



希望这有助于!


I have a Webrowser with some settings that are changed using javascript. I'm trying to use the example here but can't get the correct syntax

the script looks like this

        <div class="DisplayInput"><input type="radio" name="displaytype" 
value="decimal" onclick="setdisplayType('decimal');" checked="checked"><a 
    href="javaScript:setdisplayType('decimal');" 
    onclick="s_objectID=&quot;javascript:setdisplayType('decimal');_1&quot;;return this.s_oc?     this.s_oc(e):true">Decimal</a></div>

So far I've tried these with no success

this.webBrowser1.InvokeScript("setdisplayType");
this.webBrowser1.InvokeScript("setdisplayType('decimal')");
this.webBrowser1.InvokeScript("setdisplayType","decimal");

解决方案

Without knowing what's happening with your application's error and also not knowing what setdisplayType looks like, I'm guessing that maybe you're trying to invoke the function setdisplayType before it's been loaded. Per the MSDN documentation...

InvokeScript(String, Object()) should not be called before the document that implements it has finished loading. You can detect when a document has finished loading by handling the LoadCompleted event.

Maybe you can implement the LoadCompleted event handler and then invoke your script.

Hope this helps!

这篇关于web浏览器InvokeScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆