Calling delphi function from javascript
I can call the Delphi function from the HTML as in the example. But when I put the Delphi function into a javascript function it does not work. See Below.
function responseTimer()
{
delphi:PlaySound(); //beep.play();
rspTime++;
httpGet("get_is_alarm_rsp_acked.cgi?AlarmId="+alarmResponse.AlarmId, function()
{
if(this.responseText == "TRUE")
{
if (TID !== undefined)
clearTimeout(TID);
showPage("timer", "monitor");
startMonitor();
}
});
document.getElementById("counter").innerHTML =
parseInt(rspTime / 60) + ":" + ("0" + rspTime % 60).substr(-2);
if (rspSetting.RspTimeout == rspTime)
{
httpPOST_JSON("set_alarm_rsp_values.cgi", alarmResponse);
showPage("timer", "monitor");
startMonitor();
}
else
TID = setTimeout(responseTimer, 1000);
}
Comments (6)
-
-
repo owner - changed status to resolved
This is not bug.
-
I also met this problem,like this?
function responseTimer() { location = "delphi:PlaySound();"; }
-
location = "delphi:PlaySound()";
-
how to get function result; delphi function getdata():string;
js how to call getdata, get result
-
document.location = "yourorgScheme:YourDelphiProcedure(Parameters1, Parameter2, Etc)";
This code works
#! Javascript
document.location = "yourorgScheme:ReadManualLocation(''"+latitude+"'',''"+longitude+"'')";
#! Delphi
procedure TForm1.ReadManualLocation(latitude,longitude: String); begin ShowMessage(latitude); ShowMessage(longitude); end;
#! Notice the parameters during call , (SINGLEQUOTE SINGLEQUOTE DOUBLEQUOTE + latitude + DOUBLEQUOTE SINGLEQUOTE SINGLEQUOTE ,
#! Notice it also works with one single quote only , (SINGLEQUOTE DOUBLEQUOTE + latitude + DOUBLEQUOTE SINGLEQUOTE ,
#! JavaScript single quote
function onMapClick(e) { // get selected latitude var latitude= e.latlng.lat; // get select longitude var longitude= e.latlng.lng; document.location = "yourorgScheme:ReadManualLocation('"+latitude+"','"+longitude+"')"; myMarker.setLatLng(e.latlng); }
- Log in to comment
Your JavaScript is incorrectly written.
For example, please write as follows.