I want to use jscript to set cookie inside my JavaFX application in browser .
I tried to use JsObject for this purpose but it did not work properly and is throwing an exception:
SECURITY_ERR: DOM Exception 18
This is the code I used:
public static void writeCookies(String data) {
WebEngine engine = new WebEngine();
JSObject doc = (JSObject) engine.getDocument();
data = cookieName + "=" + data + "; expires=" + Helpers.getGMTexpireDate(120);
doc.setMember("cookie", data);
}
I was using JSObject.getWindow(this)
and executing jscript code in Applet, but in JavaFX, getting JSObject in such a way does not work. I can force it to work only by removing jfxrt.jar. (solving a conflict between jxfrt.jar and plugin.jar).
Unfortunately, this option does not suit us because the project highly depends on JavaFX fxml.
How can i properly call jscript functions from JavaFX?