I'm a beginner of javafx. this is my function of javascript in my html file
function setMap(mapExtent) { if (mapExtent) { var args = mapExtent.split(","); if (args.length >= 4) { frx = parseFloat(args[0]); fry = parseFloat(args[1]); frzoom = parseInt(args[2]); frMapType = args[3]; if (pMap) { pMap.SetMap(mapExtent); } } } }
I know how to invoke it in C#, like this:
public void setMap(string sExtend) { object[] objArray = new object[1]; objArray[0] = sExtend; try { this.Document.InvokeScript("setMap", objArray); } catch { } }
this javascript function need pass a parameter(a javascript object), but in the API document of JAVAFX8, the parameter of method webengine.executeScript(String script) is a String type only. How to use webengine.executeScript() invoke the setMap(string sExtend)
Get the window object
JSObject jsObject = (JSObject) webEngine.executeScript("window");
then try to call
jsObject.call("setMap", sExtend);
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.