Click here to Skip to main content
15,850,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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



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

This is my Html code.

JavaScript
<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?
Posted
Updated 8-Jun-12 0:25am
v4

1 solution

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.
 
Share this answer
 
Comments
ZaiDz 8-Jun-12 6:31am    
No, didn't change anything.
Any more suggestions?
Toshichka 13-Nov-13 3:51am    
does any one has a solution for this isue?
Any time when I change geckoWebBrowser.Document.Body.InnerHtml java scrypt stop working
Even when I try to this
String tmp = geckoWebBrowser.Document.Body.InnerHtml;
geckoWebBrowser.Document.Body.InnerHtml = tmp ;
markovl 8-Jun-12 7:01am    
Nope, sorry.
Maybe it's best to take your question to the vendor of the control. I assume you're using GeckoFX's component? They'd be of better help.
ZaiDz 8-Jun-12 14:49pm    
Their forums aren't very active.
ZaiDz 8-Jun-12 6:40am    
If I save the code into an html file then write browser.Navigate(FILELOCATION) it works just fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900