Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: WebEngine

[10:7] extends: FxObj

Wraps JavaFX WebEngine, the non-visual web page loader and DOM manager embedded inside a WebView. Use it to load URLs, inject HTML content, run JavaScript, and query the current page location. Obtain an instance via WebView.getEngine().

Methods

  • load (string Url)

    Loads the web page at the given URL into the engine.

    • @p Url is a string with the URL to load (e.g., "https://example.com").
    • @r this object
  • loadContent (string HtmlContent)

    Loads the given HTML string directly into the engine as a new page.

    • @p HtmlContent is a string containing the HTML markup to render.
    • @r this object
  • getLocation ()

    Returns the URL of the currently loaded page.

    • @r A string with the current page URL, or an empty string if no page is loaded.
  • getTitle ()

    Returns the title of the currently loaded page.

    • @r A string with the page title, or null if no title is set.
  • executeScript (string Script)

    Executes a JavaScript expression in the context of the currently loaded page.

    • @p Script is a string containing the JavaScript expression to evaluate.
    • @r The result of the JavaScript expression, or null for void results.
  • reload ()

    Reloads the currently loaded page.

    • @r this object
  • getLoadWorker ()

    Returns the LoadWorker tracking the progress of the current load.

    • @r An AJO wrapping javafx.concurrent.Worker.
  • getDocument ()

    Returns the parsed DOM Document for the currently loaded page, or null when no page has been loaded yet.

    • @r An AJO wrapping org.w3c.dom.Document, or null.
  • documentProperty ()

    Returns the read-only ObjectProperty backing the parsed DOM document.

    • @r An AJO wrapping javafx.beans.property.ReadOnlyObjectProperty.
  • locationProperty ()

    Returns the read-only StringProperty backing the current page URL.

    • @r An AJO wrapping javafx.beans.property.ReadOnlyStringProperty.
  • titleProperty ()

    Returns the read-only StringProperty backing the current page title.

    • @r An AJO wrapping javafx.beans.property.ReadOnlyStringProperty.
  • setJavaScriptEnabled (bool Enabled)

    Enables or disables JavaScript execution in the engine.

    • @p Enabled is a bool; true allows JavaScript to run.
    • @r this object for chaining
  • isJavaScriptEnabled ()

    Returns whether JavaScript execution is currently enabled.

    • @r A bool; true when JavaScript is allowed.
  • javaScriptEnabledProperty ()

    Returns the BooleanProperty backing the JavaScript-enabled flag.

    • @r An AJO wrapping javafx.beans.property.BooleanProperty.
  • setUserStyleSheetLocation (string Location)

    Sets the location of the user-supplied style sheet (CSS) applied on top of the page's own styles. Pass a URL or data: URI; pass null to clear.

    • @p Location is a string URL pointing at the CSS, or null.
    • @r this object for chaining
  • getUserStyleSheetLocation ()

    Returns the location of the user-supplied style sheet.

    • @r A string with the CSS URL, or null when unset.
  • userStyleSheetLocationProperty ()

    Returns the StringProperty backing the user style sheet location.

    • @r An AJO wrapping javafx.beans.property.StringProperty.
  • getUserDataDirectory ()

    Returns the directory used to store user-data for this engine, or null when JavaFX has chosen no directory yet.

    • @r An AJO wrapping java.io.File, or null.
  • setUserDataDirectory (string Dir)

    Sets the directory used to store user-data for this engine.

    • @p Dir is a string with the absolute directory path.
    • @r this object for chaining
  • userDataDirectoryProperty ()

    Returns the ObjectProperty backing the user-data directory.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty.
  • setUserAgent (string Agent)

    Sets the user-agent string sent with HTTP requests.

    • @p Agent is a string with the user-agent header value.
    • @r this object for chaining
  • getUserAgent ()

    Returns the current user-agent string.

    • @r A string with the user-agent value.
  • userAgentProperty ()

    Returns the StringProperty backing the user-agent string.

    • @r An AJO wrapping javafx.beans.property.StringProperty.
  • getOnAlert ()

    Returns the current onAlert handler.

    • @r An AJO wrapping javafx.event.EventHandler<WebEvent>.
  • setOnAlert (callback OnAlert)

    Registers a handler for JavaScript alert() calls.

    • @p OnAlert is a callback invoked with a WebEvent payload.
    • @r this object for chaining
  • onAlertProperty ()

    Returns the ObjectProperty backing the onAlert handler.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<EventHandler<WebEvent>>.
  • getOnStatusChanged ()

    Returns the current onStatusChanged handler.

    • @r An AJO wrapping javafx.event.EventHandler<WebEvent>.
  • setOnStatusChanged (callback OnStatus)

    Registers a handler for window.status changes.

    • @p OnStatus is a callback invoked with a WebEvent payload.
    • @r this object for chaining
  • onStatusChangedProperty ()

    Returns the ObjectProperty backing the onStatusChanged handler.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<EventHandler<WebEvent>>.
  • getOnResized ()

    Returns the current onResized handler.

    • @r An AJO wrapping javafx.event.EventHandler<WebEvent>.
  • setOnResized (callback OnResize)

    Registers a handler for window.resize requests issued by the page.

    • @p OnResize is a callback invoked with a WebEvent payload.
    • @r this object for chaining
  • onResizedProperty ()

    Returns the ObjectProperty backing the onResized handler.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<EventHandler<WebEvent>>.
  • getOnVisibilityChanged ()

    Returns the current onVisibilityChanged handler.

    • @r An AJO wrapping javafx.event.EventHandler<WebEvent>.
  • setOnVisibilityChanged (callback OnVis)

    Registers a handler for window.visibility change requests.

    • @p OnVis is a callback invoked with a WebEvent payload.
    • @r this object for chaining
  • onVisibilityChangedProperty ()

    Returns the ObjectProperty backing the onVisibilityChanged handler.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<EventHandler<WebEvent>>.
  • getCreatePopupHandler ()

    Returns the current createPopupHandler callback.

    • @r An AJO wrapping javafx.util.Callback<PopupFeatures, WebEngine>.
  • setCreatePopupHandler (callback OnCreate)

    Registers a callback that builds the WebEngine to back JavaScript popup windows opened by the page.

    • @p OnCreate is a callback invoked with a PopupFeatures argument.
    • @r this object for chaining
  • createPopupHandlerProperty ()

    Returns the ObjectProperty backing the createPopupHandler callback.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<Callback<PopupFeatures, WebEngine>>.
  • getConfirmHandler ()

    Returns the current confirm() handler.

    • @r An AJO wrapping javafx.util.Callback<String, Boolean>.
  • setConfirmHandler (callback OnConfirm)

    Registers a handler for JavaScript confirm() calls. The callback returns a Boolean accept/reject answer.

    • @p OnConfirm is a callback invoked with the confirm message string.
    • @r this object for chaining
  • confirmHandlerProperty ()

    Returns the ObjectProperty backing the confirm handler.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<Callback<String, Boolean>>.
  • getPromptHandler ()

    Returns the current prompt() handler.

    • @r An AJO wrapping javafx.util.Callback<PromptData, String>.
  • setPromptHandler (callback OnPrompt)

    Registers a handler for JavaScript prompt() calls. The callback receives a PromptData payload and returns the prompt text (or null to cancel).

    • @p OnPrompt is a callback invoked with a PromptData object.
    • @r this object for chaining
  • promptHandlerProperty ()

    Returns the ObjectProperty backing the prompt handler.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<Callback<PromptData, String>>.
  • getOnError ()

    Returns the current onError handler.

    • @r An AJO wrapping javafx.event.EventHandler.
  • setOnError (callback OnError)

    Registers a handler for engine error events such as load failures.

    • @p OnError is a callback invoked with a WebErrorEvent.
    • @r this object for chaining
  • onErrorProperty ()

    Returns the ObjectProperty backing the onError handler.

    • @r An AJO wrapping javafx.beans.property.ObjectProperty<EventHandler>.
  • getHistory ()

    Returns the navigation history object for this engine.

    • @r An AJO wrapping javafx.scene.web.WebHistory.
  • print (object Job)

    Prints the current page using the given PrinterJob.

    • @p Job is an AJO wrapping a javafx.print.PrinterJob.
    • @r this object for chaining