为什么这段代码不能在gecko webbrowser中运行? [英] Why isn't this code working in gecko webbrowser?

查看:217
本文介绍了为什么这段代码不能在gecko webbrowser中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中,我正在使用gecko webbrowser,我只是在进行一些测试,我有一个richtextbox,我将这段代码更改为文本



< pre lang =c#> geckoWebBrowser1.Document.Body.InnerHtml = richTextBox1.Text;







现在一切正常,除了我无法让javascripting正常工作。



这是我的Html代码。



< script> 
function test(t)
{
if (t。 value == test
t.value = TEST;
else
t.value = 测试;
}
< / script>

< input type = button onclick = test(this) value = test> < / 输入 >





如何让java脚本在gecko浏览器中运行?

解决方案

首先,我认为输入元素不能有结束标记,因此请将标记调整为看起来像这样:

< input type =buttononclick =test(this)value =test/> 



另外,将type属性提供给脚本元素:



< script type =text / javascript> 





也许Gecko引擎将这些视为错误,因此代码没有执行ed。



我希望这会有所帮助。


In C# I'm using the gecko webbrowser and I'm just doing some testing and I have a richtextbox and I have this code on text changed

geckoWebBrowser1.Document.Body.InnerHtml = richTextBox1.Text;




Now it all works except I can't get javascripting to work properly.

This is my Html code.

<script>
function test(t)
{
if(t.value == "test")
t.value = "TEST";
else
t.value = "test";
}
</script>

<input type="button" onclick="test(this)" value="test" ></input>



How do I get the java scripting to work in the gecko browser?

解决方案

First, I think the input element can't have a closing tag, so adjust your markup to look like this:

<input type="button" onclick="test(this)" value="test" />


Also, supply the type attribute to the script element:

<script type="text/javascript">



Maybe the Gecko engine treats these as errors and thus the code doesn't get executed.

I hope this helps.


这篇关于为什么这段代码不能在gecko webbrowser中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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