Can't get javafx and webview to handle google javascript -
i having issues getting javafx listen on google results. i'm sure it's due javascript live results can't find way around it.
document doc = engine.getdocument(); nodelist elements = doc.getelementsbytagname("a"); for(int i=0; < elements.getlength();i++){ ((eventtarget) elements.item(i)).addeventlistener("click", listener, false); }
in chrome browser i'm able right click result , inspect. dom shows fine. how have javafx replicate chrome browser can do?
i able so:
class1 javafx webview application class2 bridge between javascript , java
in class1 created method so. can used upon clicking button.
private void setjslisteners(){ class2 bridge = new class2(); jsobject hrefwindow = (jsobject) engine.executescript("window"); hrefwindow.setmember("java", bridge); engine.executescript("var links = document.getelementsbytagname(\"a\");" + "for (var = 0; < links.length; i++) {" + "links[i].addeventlistener(\"click\", function(){" + "java.log(this.getattribute(\"href\"));" + "});" + "}"); }
in class2 log method looks this.
public void log(string text) { system.out.println(text); }
Comments
Post a Comment