當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。