Home > Software engineering >  VC call JS function failure is how to return a responsibility?
VC call JS function failure is how to return a responsibility?

Time:09-25

Add in the HTML document has a JS function (test program)




<meta name="viewport" content="initial - scale=1.0, user - scalable=no"/& gt;
<meta HTTP - equiv="content-type" Content="text/HTML. GBK charset="/& gt;
Baidu Map
</script>

<body>





Var map=new BMap. The map (" container ");//the new Map
Var point=new BMap. Point (116.0123, 40.1234);//the Location (longitude and latitude)
Map. CenterAndZoom (point, 10);//show the Map

Var mark=new BMap. Marker (point);
The map. The addOverlay (mark);

//var info=new BMap. InfoWindow (coordinates);
The map. The addEventListener (" click ",
The function (e)
{
Alert (e.p oint. LNG + "" + e.p oint. Lat);
}
);


//custom JS function, positioning and real-time calibration


//add the zoom function
Map. EnableScrollWheelZoom ();
Map. EnableKeyboard ();
Map. AddControl (new BMap. OverviewMapControl ());//add eagle eye controls to map
//map. AddControl (new BMap. OverviewMapControl ({1} isOpen:));//open the eagle eye
Map. AddControl (new BMap. NavigationControl ());//add bones to map (default)
//map. AddControl (new BMap. ScaleControl ());//add scale to map
Map. AddControl (new BMap. ScaleControl ({offset: new BMap. Size (5, 40)}));//add a take the scale of the deviation of the
Map. AddControl (new BMap. MapTypeControl ());//add 2 d switch controls to map
Map. SetCurrentCity (" Beijing ");//only when setting city information, MapTypeControl switching function can be available
</script>

The function TansTo (lat and LNG)//turn to the specified location, there are two parameters, latitude and longitude
{
//alert (LNG);//test parameters are passed
//var longi=parseFloat (LNG);//afterwards just know, don't have to type conversion, javascript can automatically convert
//var lati=parseFloat (lat);
Map. PanTo (new GLatLng (lat and LNG));
return 1;
}


The function to the Add (value1, value2) {
Return value1 + value2;
}
</script>



Call a function in the VC Add:
CWebPage web;
Web. SetDocument (m_webBrowser GetDocument ());
CComVariant varResult;//store the return value

Web. CallJScript (" Add ", "10", "20", & amp; VarResult); Call//JS function. The function name is TranTo, parameter is double, double
If (varResult intVal==30)
{
MessageBox (" ADD call success!" );
}
The else
{
MessageBox (" Add call failed!" );
}

The CallJScript function declarations in CWebPage is:
Bool CWebPage: : CallJScript (const cstrings strFunc, const cstrings strArg1, const cstrings strArg2, CComVariant * pVarResult)
{
CStringArray paramArray;
ParamArray. Add (strArg1);
ParamArray. Add (strArg2);
Return CallJScript (strFunc paramArray, pVarResult);
}
I asked the question is: what I passed in VC CallJScript call the Add function, parameters passed respectively is 10, 20,
Web. CallJScript (" Add ", "10", "20", & amp; VarResult), the returned result is not correct? Because I have a problem of JS function to write HTML or VC call JS
Function in the wrong way? Post a bit repetitive, great god please help solve, the younger brother grateful to disrespect

CodePudding user response:

Search "VC interact with JavaScript (a)"

CodePudding user response:

I have already solved, thank you

CodePudding user response:

http://bbs.csdn.net/topics/392080839
Here is what you want
  • Related