InvokeScript() 方法返回 null。
JavaScript:
function gpsToAddress(gpsX, gpsY) {
var coords = new daum.maps.LatLng(gpsX, gpsY);
geocoder.coord2detailaddr(coords, CallbackA)}
function CallbackA(status, result) {
if(status===daum.maps.services.Status.OK)
{
return result[0].jibunaddress;
}
}
和 C#:
private void f_ret_gpstoaddress(double v_gps_x, double v_gps_y,out string v_address)
{
object[] args = { "gpsToAddress(" + v_gps_x + "," + v_gps_y + ");" };
v_address = (string)webBrowser1.Document.InvokeScript("eval", args);
return;
}
private void button3_Click(object sender, EventArgs e)
{
f_ret_gpstoaddress(37.353933, 127.944739, out v_address);
MessageBox.Show(v_address);
}
'args' 和 'v_address' 返回 null,messageBox 也返回 null。我想返回一些值。请帮我!
编辑:好的,我编辑了这样的 C# 代码:
private string f_ret_gpstoaddress(double v_gps_x, double v_gps_y, out string v_address)
{
var args = "gpsToAddress(" + v_gps_x + "," + v_gps_y + ");" ;
v_address = webBrowser1.Document.InvokeScript("eval",new object[] { args }).ToString();
return v_address;
}
private void button3_Click(object sender, EventArgs e)
{
f_ret_gpstoaddress(37.353933, 127.944739, out v_address);
MessageBox.Show(v_address);
}
因此, args 不为空,但 v_address 仍然为空。什么问题??