1

i am Writing a simple code to add 2 no. I declare the variable in java script and give argument from vb. in Script part

enter code here
function javascriptFunction() {
var x;
var y;
var z = x + y;
alert(z);

and in Vb part i write

enter code here
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Me.WebBrowser1.Document.InvokeScript("javascriptFunction", _
New String() {"2", "3"})
End Sub

i am new In javascript.So plz any suggestion

2
  • A few observations: 1.) Not java script, but javascript. 2.) How do you want to pass a value to javascript from a different language? Commented May 22, 2015 at 9:43
  • @SimoEndre It's possible because he forgot to tell that he's invoking js inside a WebBrowser control in .Net Winforms Commented May 22, 2015 at 9:44

1 Answer 1

2

Your javascript function doesn't receive any parameters as it's declared now. It should be declared as:

function javascriptFunction(x, y) {
    var z = x + y;
    alert(z);
}
Sign up to request clarification or add additional context in comments.

2 Comments

@SimoEndre Why not? He's passing the params correctly, but there isn't any js function that match with those parameters right now. msdn.microsoft.com/en-us/library/4b1a88bz%28v=vs.110%29.aspx
It is working .. The result shows as string...@ Simo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.