Calling JS in a browser object from LC?
Posted: Wed Oct 14, 2020 1:57 pm
Is there an up-to-date example or instructions that show how to call a JavaScript handler in a browser widget and get the result? I've been trawling threads here without finding something definitive. I've also looked at the 'Livecode Javascript communication' video on YouTube but that's based on LC 6.7.
I have an HTML page with embedded JavaScript. This shows an interactive 360 panoramic image, and the JavaScript is used in that to return the current view parameters (horizontal and vertical direction and zoom level). This is the JavaScript:
I'd like to be able to call this JS function from a LiveCode button and get the same results so I can make use of the data within the regular LC environment. Does anyone have pointers or a sample stack so I can set off in the right direction?
k
I have an HTML page with embedded JavaScript. This shows an interactive 360 panoramic image, and the JavaScript is used in that to return the current view parameters (horizontal and vertical direction and zoom level). This is the JavaScript:
Code: Select all
function get_current_view()
{
if (krpano)
{
var hlookat = krpano.get("view.hlookat");
var vlookat = krpano.get("view.vlookat");
var fov = krpano.get("view.fov");
var distortion = krpano.get("view.distortion");
document.getElementById("currentview").innerHTML =
'hlookat="' + hlookat.toFixed(2) + '" '+
'vlookat="' + vlookat.toFixed(2) + '" '+
'fov="' + fov.toFixed(2) + '" '+
'distortion="' + distortion.toFixed(2) + '"';
}
}
k