I am doing a simple program in Silverlight to inkove javascript function in silverlight.
The silverlight function is as under
void InvokeJS(params object[] items)
{
object result = System.Windows.Browser.HtmlPage.Window.Invoke("JSFunction", items);
}
Pasing value to this function is happening as under
InvokeJS((object)new object[]{ (object)"10", (object)"20"})
And the JS function is as under
function JSFunction(params) {
alert(params);
}
Now how to read the params value in javascript?
To the called function, the params array is just that, an array.
In this case you will have an array that looks like this:
[ [ "10", "20" ] ]
The params
variable is just the first of many arguments being passed in. You can access the other arguments using the following syntax:
alert(this.arguments[0]);
alert(this.arguments[1]);
alert(this.arguments[2]);
If you're passing all the arguments in a single variable, it will be an array so use:
alert(params[0]);
alert(params[1]);
alert(params[2]);
我知道了
alert(params[0]); alert(params[1]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.