GeckoWebBrowser in vb.net

467 views Asked by At

I'am trying to run JavaScript code inside GeckoWebBrowser

my current code is :

 GeckoWebBrowser1.Navigate("javascript:void(" + TextBox2.Text + ")")


textbox2.text contains :

alert('test');


it run normally , but when I try to use multiline JavaScript
example :

var r = confirm("Press a button");
if (r == true) {
    x = "You pressed OK!";
} else {
    x = "You pressed Cancel!";
}

the browser run nothing , Please Help Me
Thanks

1

There are 1 answers

0
InbetweenWeekends On

It's probably generating a javascript error that your browser control is not revealing. When I create a simple page to reproduce what you're describing, clicking the link in Chrome gives:

Uncaught SyntaxError: Unexpected token var

<html>
<body>
    <a href="javascript:void(var r = confirm('Press a button');
if (r == true) {
    x = 'You pressed OK!';
} else {
    x = 'You pressed Cancel!';
    })">Link</a>
</body>
</html>