0
使用JavaFX的WebView,我可以得到一個瀏覽器實例的「窗口」 [1]:如何將'window'JSObject從一個瀏覽器傳遞給另一個瀏覽器?
// Java code
netscape.javascript.JSObject win = (JSObject) webengine.executeScript("window");
然後我就可以通過這個JSObject另一個瀏覽器實例[2],並在此瀏覽器的JavaScript,我可以操作和訪問的第一個瀏覽器實例[1]這樣的DOM,變量和函數:
// Javascript code
// get 'window' netscape.javascript.JSObject of 'browser1' webview
// control from the getWindow() method in my linked Java class
var window1 = javaObj.getWindow("browser1");
// get variables defined in 'browser1' javascript
var rString = window1.myString;
var rNum = window1.myNumber;
// execute the 'myAlert' function on 'browser1' and pass variables in
window1.myAlert(rString + " - " + rNum + "<br><br>" + Date());
// manipulate the DOM on 'browser1'
window1.document.getElementById("myLabel").style.backgroundColor = "red";
如何我jxBrowser實現這一目標?