当前位置: 首页>>代码示例>>Java>>正文


Java WebEngine.executeScript方法代码示例

本文整理汇总了Java中javafx.scene.web.WebEngine.executeScript方法的典型用法代码示例。如果您正苦于以下问题:Java WebEngine.executeScript方法的具体用法?Java WebEngine.executeScript怎么用?Java WebEngine.executeScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.web.WebEngine的用法示例。


在下文中一共展示了WebEngine.executeScript方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getListener

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
private ChangeListener<Worker.State> getListener(final DropboxManager.DropboxAccountLinkListener dropboxAccountLinkListener,
                                                 final DbxWebAuthNoRedirect webAuth, final WebEngine engine, final Stage stage) {
    return (observable, oldValue, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            try {
                final String authCode = (String) engine.executeScript("document.getElementById('auth-code').textContent");
                LOGGER.debug("Authorization Code [{}]", authCode);
                DbxAuthFinish authFinish = webAuth.finish(authCode);

                String accessToken = authFinish.accessToken;
                final DbxAuthInfo dbxAuthInfo = new DbxAuthInfo(accessToken, DbxHost.Default);
                DbxAuthInfo.Writer.writeToFile(dbxAuthInfo, accessTokenFile);

                DbxClient client = new DbxClient(dropboxConfig, dbxAuthInfo.accessToken, dbxAuthInfo.host);

                final String displayName = client.getAccountInfo().displayName;
                LOGGER.info("Linked account [{}]", displayName);
                stage.close();
                dropboxAccountLinkListener.accountLinked(AccountInfoFactory.getAccountInfo(client.getAccountInfo()));
            } catch (Exception e) {
                // ignore
            }
        }
    };
}
 
开发者ID:adelolmo,项目名称:biblio,代码行数:26,代码来源:DropboxLinkDialog.java

示例2: executejQuery

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
private static Object executejQuery(final WebEngine engine, String minVersion, String jQueryLocation, String script) {
    return engine.executeScript(
            "(function(window, document, version, callback) { "
            + "var j, d;"
            + "var loaded = false;"
            + "if (!(j = window.jQuery) || version > j.fn.jquery || callback(j, loaded)) {"
            + " var script = document.createElement(\"script\");"
            + " script.type = \"text/javascript\";"
            + " script.src = \"" + jQueryLocation + "\";"
            + " script.onload = script.onreadystatechange = function() {"
            + " if (!loaded && (!(d = this.readyState) || d == \"loaded\" || d == \"complete\")) {"
            + " callback((j = window.jQuery).noConflict(1), loaded = true);"
            + " j(script).remove();"
            + " }"
            + " };"
            + " document.documentElement.childNodes[0].appendChild(script) "
            + "} "
            + "})(window, document, \"" + minVersion + "\", function($, jquery_loaded) {" + script + "});");
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:20,代码来源:JavaFXBrowserWithHistory.java

示例3: executejQuery

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
/**
* Executes a script which may reference jQuery function on a document.
* Checks if the document loaded in a webEngine has a version of jQuery corresponding to
* the minimum required version loaded, and, if not, then loads jQuery into the document
* from the default JQUERY_LOCATION.
* @param engine the webView engine to be used.
* @Param jQueryLocation the location of the jQuery script to be executed.
* @param minVersion the minimum version of jQuery which needs to be included in the document.
* @param script provided javascript script string (which may include use of jQuery functions on the document).
* @return the result of the script execution.
*/
  private static Object executejQuery(final WebEngine engine, String minVersion, String jQueryLocation, String script) {
    return engine.executeScript(
      "(function(window, document, version, callback) { "
        + "var j, d;"
        + "var loaded = false;"
        + "if (!(j = window.jQuery) || version > j.fn.jquery || callback(j, loaded)) {"
        + " var script = document.createElement(\"script\");"
        + " script.type = \"text/javascript\";"
        + " script.src = \"" + jQueryLocation + "\";"
        + " script.onload = script.onreadystatechange = function() {"
        + " if (!loaded && (!(d = this.readyState) || d == \"loaded\" || d == \"complete\")) {"
        + " callback((j = window.jQuery).noConflict(1), loaded = true);"
        + " j(script).remove();"
        + " }"
        + " };"
        + " document.documentElement.childNodes[0].appendChild(script) "
        + "} "
      + "})(window, document, \"" + minVersion + "\", function($, jquery_loaded) {" + script + "});"
    );
  }
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:32,代码来源:JQueryWebView.java

示例4: connectToWebEngine

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
private static void connectToWebEngine(WebEngine engine, String varname) {
    if (	backendObjects.containsKey(engine) &&
            backendObjects.get(engine).containsKey(varname)) {

        JSObject window = (JSObject) engine.executeScript("window");
        window.setMember(varname, backendObjects.get(engine).get(varname));
    }
}
 
开发者ID:jamf,项目名称:HealthCheckUtility,代码行数:9,代码来源:JavaToJavascriptBridge.java

示例5: changed

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
	if (newValue == State.SUCCEEDED) {
		WebEngine engine = getWebView().getEngine();
		if (ValueUtil.isNotEmpty(initCont)) {
			engine.executeScript(" document.getElementById('gargoyle-textarea').innerHTML= '" + initCont + "'; ");
		}

		engine.getLoadWorker().stateProperty().removeListener(this);
		webViewLoaded.set(true);
	}
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:13,代码来源:TinymceDeligator.java

示例6: start

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
    WebView view = new WebView();
    WebEngine engine = view.getEngine();
    JSObject win = (JSObject) engine.executeScript("window");
    win.setMember("scriptReady", new ScriptReady());
    engine.load(getClass().getResource(EXTERNAL_PAGE).toExternalForm());
    stage.setScene(new Scene(new BorderPane(view), 640, 480));
    stage.show();
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:11,代码来源:ExternalResourceLoadingTest.java

示例7: registerFunction

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
private void registerFunction(String functionName, WebEngine engine) {
    engine.executeScript(
        "var fun = " + functionName + " ;"
        + functionName + " = function() {"
        + "    app.functionCalled('" + functionName + "');"
        + "    fun.apply(this, arguments)"
        + "}"
    );
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:10,代码来源:BrowserJavascript.java

示例8: connectToWebEngine

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
private static void connectToWebEngine(WebEngine engine, String varname) {
	if (	backendObjects.containsKey(engine) &&
			backendObjects.get(engine).containsKey(varname)) {
		
		JSObject window = (JSObject) engine.executeScript("window");
		window.setMember(varname, backendObjects.get(engine).get(varname));
	}
}
 
开发者ID:lipido,项目名称:javafxwebview,代码行数:9,代码来源:Java2JavascriptUtils.java

示例9: setUp

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    final WebEngine webEngine = new WebEngine();

    Object obj = webEngine.executeScript("({ text: 'message', number: 42, boolean: true," +
            "func: function() {}, object: { foo: 'bar' }, array: [1, 3, 5] })");

    assertTrue(obj instanceof JSObject);
    this.jsObject = (JSObject) obj;
}
 
开发者ID:nanase,项目名称:Nanasetter,代码行数:11,代码来源:JSObjectUtilsTest.java

示例10: Bridge

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
Bridge(WebEngine engine){
            this.engine=engine;
//            engine.executeScript("$(document).ready(function() {"+
//            		"updateMethodName='"+update()+"'; " + 
//            		"});");
            engine.executeScript("updateMethodName='"+update()+"'; ");
        }
 
开发者ID:Warfront1,项目名称:AutoFletcherElite,代码行数:8,代码来源:Paint.java

示例11: onLoaded

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Override
public void onLoaded(WebEngine webkit) {
	this.webkit = webkit;
	JSObject window = (JSObject) webkit.executeScript("window");
	window.setMember("java", new JsHandler());
	refresh();
}
 
开发者ID:GreenDelta,项目名称:olca-app,代码行数:8,代码来源:PluginManager.java

示例12: onLoaded

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Override
public void onLoaded(WebEngine webkit) {
	JSObject win = (JSObject) webkit.executeScript("window");
	win.setMember("java", new JsHandler());
	String version = M.Version + " " + Config.VERSION + " ("
			+ OS.getCurrent() + " " + getArch() + ")";
	webkit.executeScript("document.getElementById('version').innerHTML = '"
			+ version + "'");
}
 
开发者ID:GreenDelta,项目名称:olca-app,代码行数:10,代码来源:StartPage.java

示例13: onLoaded

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Override
public void onLoaded(WebEngine webkit) {
	log.trace("page completed, set data");
	UI.bindVar(webkit, "java", new JsHandler());
	try {
		List<CategorizedDescriptor> list = runSearch();
		Gson gson = new Gson();
		String json = gson.toJson(list);
		String command = "setData(" + json + ")";
		webkit.executeScript(command);
	} catch (Exception e) {
		log.trace("Failed to load data: where used", e);
	}
}
 
开发者ID:GreenDelta,项目名称:olca-app,代码行数:15,代码来源:UsageView.java

示例14: onLoaded

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Override
public void onLoaded(WebEngine webkit) {
	Gson gson = new Gson();
	String json = gson.toJson(report);
	String messages = M.asJson();
	String command = "setData(" + json + ", " + messages + ")";
	try {
		webkit.executeScript(command);
	} catch (Exception e) {
		log.error("failed to set report data to browser", e);
	}
}
 
开发者ID:GreenDelta,项目名称:olca-app,代码行数:13,代码来源:ReportViewer.java

示例15: onLoaded

import javafx.scene.web.WebEngine; //导入方法依赖的package包/类
@Override
public void onLoaded(WebEngine webkit) {
	UI.bindVar(webkit, "java", new Js());
	Gson gson = new Gson();
	for (Comment comment : comments.getForPath(path)) {
		webkit.executeScript("add(" + gson.toJson(comment) + ", true);");
	}
}
 
开发者ID:GreenDelta,项目名称:olca-app,代码行数:9,代码来源:CommentDialog.java


注:本文中的javafx.scene.web.WebEngine.executeScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。