为什么这段代码不能在gecko webbrowser中运行? [英] Why isn't this code working in 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 theinput
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 thescript
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屋!