# Class WebEngine

java.lang.Object
javafx.scene.web.WebEngine

public final class WebEngine extends Object
`WebEngine` is a non-visual object capable of managing one Web page at a time. It loads Web pages, creates their document models, applies styles as necessary, and runs JavaScript on pages. It provides access to the document model of the current page, and enables two-way communication between a Java application and JavaScript code of the page.

Loading Web Pages

The `WebEngine` class provides two ways to load content into a `WebEngine` object:

- From an arbitrary URL using the `load(java.lang.String)` method. This method uses the `java.net` package for network access and protocol handling.
- From an in-memory String using the `loadContent(java.lang.String, java.lang.String)` and `loadContent(java.lang.String)` methods.

Loading always happens on a background thread. Methods that initiate loading return immediately after scheduling a background job. To track progress and/or cancel a job, use the `Worker` instance available from the `getLoadWorker()` method.

The following example changes the stage title when loading completes successfully:

        import javafx.concurrent.Worker.State;
        final Stage stage;
        webEngine.getLoadWorker().stateProperty().addListener(
            new ChangeListener<State>() {
                public void changed(ObservableValue ov, State oldState, State newState) {
                    if (newState == State.SUCCEEDED) {
                        stage.setTitle(webEngine.getLocation());
                    }
                }
            });
        webEngine.load("http://javafx.com");

User Interface Callbacks

A number of user interface callbacks may be registered with a `WebEngine` object. These callbacks are invoked when a script running on the page requests a user interface operation to be performed, for example, opens a popup window or changes status text. A `WebEngine` object cannot handle such requests internally, so it passes the request to the corresponding callbacks. If no callback is defined for a specific operation, the request is silently ignored.

The table below shows JavaScript user interface methods and properties with their corresponding `WebEngine` callbacks:

JavaScript Callback Table
JavaScript method/property | WebEngine callback
--- | ---
`window.alert()` | `onAlert`
`window.confirm()` | `confirmHandler`
`window.open()` | `createPopupHandler`
`window.open()` and `window.close()` | `onVisibilityChanged`
`window.prompt()` | `promptHandler`
Setting `window.status` | `onStatusChanged`
Setting any of the following: `window.innerWidth`, `window.innerHeight`, `window.outerWidth`, `window.outerHeight`, `window.screenX`, `window.screenY`, `window.screenLeft`, `window.screenTop` | `onResized`

The following example shows a callback that resizes a browser window:

        Stage stage;
        webEngine.setOnResized(
            new EventHandler<WebEvent<Rectangle2D>>() {
                public void handle(WebEvent<Rectangle2D> ev) {
                    Rectangle2D r = ev.getData();
                    stage.setWidth(r.getWidth());
                    stage.setHeight(r.getHeight());
                }
            });

Access to Document Model

The `WebEngine` objects create and manage a Document Object Model (DOM) for their Web pages. The model can be accessed and modified using Java DOM Core classes. The `getDocument()` method provides access to the root of the model. Additionally DOM Event specification is supported to define event handlers in Java code.

The following example attaches a Java event listener to an element of a Web page. Clicking on the element causes the application to exit:

        EventListener listener = new EventListener() {
            public void handleEvent(Event ev) {
                Platform.exit();
            }
        };

        Document doc = webEngine.getDocument();
        Element el = doc.getElementById("exit-app");
        ((EventTarget) el).addEventListener("click", listener, false);

Evaluating JavaScript expressions

It is possible to execute arbitrary JavaScript code in the context of the current page using the `executeScript(java.lang.String)` method. For example:

        webEngine.executeScript("history.back()");

The execution result is returned to the caller, as described in the next section.

Mapping JavaScript values to Java objects

JavaScript values are represented using the obvious Java classes: null becomes Java null; a boolean becomes a `java.lang.Boolean`; and a string becomes a `java.lang.String`. A number can be `java.lang.Double` or a `java.lang.Integer`, depending. The undefined value maps to a specific unique String object whose value is `"undefined"`.

If the result is a JavaScript object, it is wrapped as an instance of the `JSObject` class. (As a special case, if the JavaScript object is a `JavaRuntimeObject` as discussed in the next section, then the original Java object is extracted instead.) The `JSObject` class is a proxy that provides access to methods and properties of its underlying JavaScript object. The most commonly used `JSObject` methods are `getMember` (to read a named property), `setMember` (to set or define a property), and `call` (to call a function-valued property).

A DOM `Node` is mapped to an object that both extends `JSObject` and implements the appropriate DOM interfaces. To get a `JSObject` object for a `Node` just do a cast:

     JSObject jdoc = (JSObject) webEngine.getDocument();

In some cases the context provides a specific Java type that guides the conversion. For example if setting a Java `String` field from a JavaScript expression, then the JavaScript value is converted to a string.

Mapping Java objects to JavaScript values

The arguments of the `JSObject` methods `setMember` and `call` pass Java objects to the JavaScript environment. This is roughly the inverse of the JavaScript-to-Java mapping described above: Java `String`, `Number`, or `Boolean` objects are converted to the obvious JavaScript values. A `JSObject` object is converted to the original wrapped JavaScript object. Otherwise a `JavaRuntimeObject` is created. This is a JavaScript object that acts as a proxy for the Java object, in that accessing properties of the `JavaRuntimeObject` causes the Java field or method with the same name to be accessed.

Note that the Java objects bound using `JSObject.setMember`, `JSObject.setSlot`, and `JSObject.call` are implemented using weak references. This means that the Java object can be garbage collected, causing subsequent accesses to the JavaScript objects to have no effect.

Calling back to Java from JavaScript

The `JSObject.setMember` method is useful to enable upcalls from JavaScript into Java code, as illustrated by the following example. The Java code establishes a new JavaScript object named `app`. This object has one public member, the method `exit`.

    public class JavaApplication {
        public void exit() {
            Platform.exit();
        }
    }
    ...
    JavaApplication javaApp = new JavaApplication();
    JSObject window = (JSObject) webEngine.executeScript("window");
    window.setMember("app", javaApp);

You can then refer to the object and the method from your HTML page:

        <a href="" onclick="app.exit()">Click here to exit application</a>

When a user clicks the link the application is closed.

Note that in the above example, the application holds a reference to the `JavaApplication` instance. This is required for the callback from JavaScript to execute the desired method.

In the following example, the application does not hold a reference to the Java object:

     JSObject window = (JSObject) webEngine.executeScript("window");
     window.setMember("app", new JavaApplication());

In this case, since the property value is a local object, `"new JavaApplication()"`, the value may be garbage collected in next GC cycle.

When a user clicks the link, it does not guarantee to execute the callback method `exit`.

If there are multiple Java methods with the given name, then the engine selects one matching the number of parameters in the call. (Varargs are not handled.) An unspecified one is chosen if there are multiple ones with the correct number of parameters.

You can pick a specific overloaded method by listing the parameter types in an "extended method name", which has the form `"method_name(param_type1,...,param_typen)"`. Typically you'd write the JavaScript expression:

     receiver["method_name(param_type1,...,param_typeN)"](arg1,...,argN)

The Java class and method must both be declared public.

Deploying an Application as a Module

If any Java class passed to JavaScript is in a named module, then it must be reflectively accessible to the `javafx.web` module. A class is reflectively accessible if the module `opens` the containing package to at least the `javafx.web` module. Otherwise, the method will not be called, and no error or warning will be produced.

For example, if `com.foo.MyClass` is in the `foo.app` module, the `module-info.java` might look like this:

    module foo.app {
        opens com.foo to javafx.web;
    }

Alternatively, a class is reflectively accessible if the module `exports` the containing package unconditionally.

Starting with JavaFX 14, HTTP/2 support has been added to WebEngine. This is achieved by using `HttpClient` instead of `URLConnection`. HTTP/2 is activated by default when JavaFX 14 (or later) is used with JDK 12 (or later).

Threading

`WebEngine` objects must be created and accessed solely from the JavaFX Application thread. This rule also applies to any DOM and JavaScript objects obtained from the `WebEngine` object.

Since:
  JavaFX 2.0

- ## Property Summary

  Properties
  Type
  Property
  Description
  `final ObjectProperty<Callback<String,Boolean>>`
  `confirmHandler`
  JavaScript `confirm` handler property.
  `final ObjectProperty<Callback<PopupFeatures, WebEngine>>`
  `createPopupHandler`
  JavaScript popup handler property.
  `final ReadOnlyObjectProperty<Document>`
  `document`
  Document object for the current Web page.
  `final BooleanProperty`
  `javaScriptEnabled`
  Specifies whether JavaScript execution is enabled.
  `final ReadOnlyStringProperty`
  `location`
  URL of the current Web page.
  `final ObjectProperty<EventHandler<WebEvent<String>>>`
  `onAlert`
  JavaScript `alert` handler property.
  `final ObjectProperty<EventHandler<WebErrorEvent>>`
  `onError`
  The event handler called when an error occurs.
  `final ObjectProperty<EventHandler<WebEvent<Rectangle2D>>>`
  `onResized`
  JavaScript window resize handler property.
  `final ObjectProperty<EventHandler<WebEvent<String>>>`
  `onStatusChanged`
  JavaScript status handler property.
  `final ObjectProperty<EventHandler<WebEvent<Boolean>>>`
  `onVisibilityChanged`
  JavaScript window visibility handler property.
  `final ObjectProperty<Callback<PromptData, String>>`
  `promptHandler`
  JavaScript `prompt` handler property.
  `final ReadOnlyStringProperty`
  `title`
  Title of the current Web page.
  `final StringProperty`
  `userAgent`
  Specifies user agent ID string.
  `final ObjectProperty<File>`
  `userDataDirectory`
  Specifies the directory to be used by this `WebEngine` to store local user data.
  `final StringProperty`
  `userStyleSheetLocation`
  Location of the user stylesheet as a string URL.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WebEngine()`
  Creates a new engine.
  `WebEngine(String url)`
  Creates a new engine and loads a Web page into it.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final ObjectProperty<Callback<String,Boolean>>`
  `confirmHandlerProperty()`
  JavaScript `confirm` handler property.
  `final ObjectProperty<Callback<PopupFeatures, WebEngine>>`
  `createPopupHandlerProperty()`
  JavaScript popup handler property.
  `final ReadOnlyObjectProperty<Document>`
  `documentProperty()`
  Document object for the current Web page.
  `Object`
  `executeScript(String script)`
  Executes a script in the context of the current page.
  `final Callback<String,Boolean>`
  `getConfirmHandler()`
  Gets the value of the `confirmHandler` property.
  `final Callback<PopupFeatures, WebEngine>`
  `getCreatePopupHandler()`
  Gets the value of the `createPopupHandler` property.
  `final Document`
  `getDocument()`
  Gets the value of the `document` property.
  `WebHistory`
  `getHistory()`
  Returns the session history object.
  `final Worker<Void>`
  `getLoadWorker()`
  Returns a `Worker` object that can be used to track loading progress.
  `final String`
  `getLocation()`
  Gets the value of the `location` property.
  `final EventHandler<WebEvent<String>>`
  `getOnAlert()`
  Gets the value of the `onAlert` property.
  `final EventHandler<WebErrorEvent>`
  `getOnError()`
  Gets the value of the `onError` property.
  `final EventHandler<WebEvent<Rectangle2D>>`
  `getOnResized()`
  Gets the value of the `onResized` property.
  `final EventHandler<WebEvent<String>>`
  `getOnStatusChanged()`
  Gets the value of the `onStatusChanged` property.
  `final EventHandler<WebEvent<Boolean>>`
  `getOnVisibilityChanged()`
  Gets the value of the `onVisibilityChanged` property.
  `final Callback<PromptData, String>`
  `getPromptHandler()`
  Gets the value of the `promptHandler` property.
  `final String`
  `getTitle()`
  Gets the value of the `title` property.
  `final String`
  `getUserAgent()`
  Gets the value of the `userAgent` property.
  `final File`
  `getUserDataDirectory()`
  Gets the value of the `userDataDirectory` property.
  `final String`
  `getUserStyleSheetLocation()`
  Gets the value of the `userStyleSheetLocation` property.
  `final boolean`
  `isJavaScriptEnabled()`
  Gets the value of the `javaScriptEnabled` property.
  `final BooleanProperty`
  `javaScriptEnabledProperty()`
  Specifies whether JavaScript execution is enabled.
  `void`
  `load(String url)`
  Loads a Web page into this engine.
  `void`
  `loadContent(String content)`
  Loads the given HTML content directly.
  `void`
  `loadContent(String content, String contentType)`
  Loads the given content directly.
  `final ReadOnlyStringProperty`
  `locationProperty()`
  URL of the current Web page.
  `final ObjectProperty<EventHandler<WebEvent<String>>>`
  `onAlertProperty()`
  JavaScript `alert` handler property.
  `final ObjectProperty<EventHandler<WebErrorEvent>>`
  `onErrorProperty()`
  The event handler called when an error occurs.
  `final ObjectProperty<EventHandler<WebEvent<Rectangle2D>>>`
  `onResizedProperty()`
  JavaScript window resize handler property.
  `final ObjectProperty<EventHandler<WebEvent<String>>>`
  `onStatusChangedProperty()`
  JavaScript status handler property.
  `final ObjectProperty<EventHandler<WebEvent<Boolean>>>`
  `onVisibilityChangedProperty()`
  JavaScript window visibility handler property.
  `void`
  `print(PrinterJob job)`
  Prints the current Web page using the given printer job.
  `final ObjectProperty<Callback<PromptData, String>>`
  `promptHandlerProperty()`
  JavaScript `prompt` handler property.
  `void`
  `reload()`
  Reloads the current page, whether loaded from URL or directly from a String in one of the `loadContent` methods.
  `final void`
  `setConfirmHandler(Callback<String,Boolean> handler)`
  Sets the value of the `confirmHandler` property.
  `final void`
  `setCreatePopupHandler(Callback<PopupFeatures, WebEngine> handler)`
  Sets the value of the `createPopupHandler` property.
  `final void`
  `setJavaScriptEnabled(boolean value)`
  Sets the value of the `javaScriptEnabled` property.
  `final void`
  `setOnAlert(EventHandler<WebEvent<String>> handler)`
  Sets the value of the `onAlert` property.
  `final void`
  `setOnError(EventHandler<WebErrorEvent> handler)`
  Sets the value of the `onError` property.
  `final void`
  `setOnResized(EventHandler<WebEvent<Rectangle2D>> handler)`
  Sets the value of the `onResized` property.
  `final void`
  `setOnStatusChanged(EventHandler<WebEvent<String>> handler)`
  Sets the value of the `onStatusChanged` property.
  `final void`
  `setOnVisibilityChanged(EventHandler<WebEvent<Boolean>> handler)`
  Sets the value of the `onVisibilityChanged` property.
  `final void`
  `setPromptHandler(Callback<PromptData, String> handler)`
  Sets the value of the `promptHandler` property.
  `final void`
  `setUserAgent(String value)`
  Sets the value of the `userAgent` property.
  `final void`
  `setUserDataDirectory(File value)`
  Sets the value of the `userDataDirectory` property.
  `final void`
  `setUserStyleSheetLocation(String value)`
  Sets the value of the `userStyleSheetLocation` property.
  `final ReadOnlyStringProperty`
  `titleProperty()`
  Title of the current Web page.
  `final StringProperty`
  `userAgentProperty()`
  Specifies user agent ID string.
  `final ObjectProperty<File>`
  `userDataDirectoryProperty()`
  Specifies the directory to be used by this `WebEngine` to store local user data.
  `final StringProperty`
  `userStyleSheetLocationProperty()`
  Location of the user stylesheet as a string URL.

  ### Methods declared in class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Property Details

  - ### document

    public final ReadOnlyObjectProperty<Document> documentProperty
    Document object for the current Web page. The value is `null` if the Web page failed to load.
    See Also:
      - `getDocument()`
      - `documentProperty()`

  - ### location

    public final ReadOnlyStringProperty locationProperty
    URL of the current Web page. If the current page has no URL, the value is an empty String.
    See Also:
      - `getLocation()`
      - `locationProperty()`

  - ### title

    public final ReadOnlyStringProperty titleProperty
    Title of the current Web page. If the current page has no title, the value is `null`. This property will be updated asynchronously some time after the page is loaded. Applications should not rely on any particular timing, but should listen for changes to this property, or bind to it, to know when it has been updated.
    See Also:
      - `getTitle()`
      - `titleProperty()`

  - ### javaScriptEnabled

    public final BooleanProperty javaScriptEnabledProperty
    Specifies whether JavaScript execution is enabled.
    Default value:
      true
    Since:
      JavaFX 2.2
    See Also:
      - `isJavaScriptEnabled()`
      - `setJavaScriptEnabled(boolean)`
      - `javaScriptEnabledProperty()`

  - ### userStyleSheetLocation

    public final StringProperty userStyleSheetLocationProperty
    Location of the user stylesheet as a string URL.

    This should be a local URL, i.e. either `'data:'`, `'file:'`, `'jar:'`, or `'jrt:'`. Remote URLs are not allowed for security reasons.

    Default value:
      null
    Since:
      JavaFX 2.2
    See Also:
      - `getUserStyleSheetLocation()`
      - `setUserStyleSheetLocation(String)`
      - `userStyleSheetLocationProperty()`

  - ### userDataDirectory

    public final ObjectProperty<File> userDataDirectoryProperty
    Specifies the directory to be used by this `WebEngine` to store local user data.

    If the value of this property is not `null`, the `WebEngine` will attempt to store local user data in the respective directory. If the value of this property is `null`, the `WebEngine` will attempt to store local user data in an automatically selected system-dependent user- and application-specific directory.

    When a `WebEngine` is about to start loading a web page or executing a script for the first time, it checks whether it can actually use the directory specified by this property. If the check fails for some reason, the `WebEngine` invokes the `WebEngine.onError` event handler, if any, with a `WebErrorEvent` describing the reason. If the invoked event handler modifies the `userDataDirectory` property, the `WebEngine` retries with the new value as soon as the handler returns. If the handler does not modify the `userDataDirectory` property (which is the default), the `WebEngine` continues without local user data.

    Once the `WebEngine` has started loading a web page or executing a script, changes made to this property have no effect on where the `WebEngine` stores or will store local user data.

    Currently, the directory specified by this property is used only to store the data that backs the `window.localStorage` objects. In the future, more types of data can be added.

    Default value:
      `null`
    Since:
      JavaFX 8.0
    See Also:
      - `getUserDataDirectory()`
      - `setUserDataDirectory(File)`
      - `userDataDirectoryProperty()`

  - ### userAgent

    public final StringProperty userAgentProperty
    Specifies user agent ID string. This string is the value of the `User-Agent` HTTP header.
    Default value:
      system dependent
    Since:
      JavaFX 8.0
    See Also:
      - `getUserAgent()`
      - `setUserAgent(String)`
      - `userAgentProperty()`

  - ### onAlert

    public final ObjectProperty<EventHandler<WebEvent<String>>> onAlertProperty
    JavaScript `alert` handler property. This handler is invoked when a script running on the Web page calls the `alert` function.
    See Also:
      - `getOnAlert()`
      - `setOnAlert(EventHandler)`
      - `onAlertProperty()`

  - ### onStatusChanged

    public final ObjectProperty<EventHandler<WebEvent<String>>> onStatusChangedProperty
    JavaScript status handler property. This handler is invoked when a script running on the Web page sets `window.status` property.
    See Also:
      - `getOnStatusChanged()`
      - `setOnStatusChanged(EventHandler)`
      - `onStatusChangedProperty()`

  - ### onResized

    public final ObjectProperty<EventHandler<WebEvent<Rectangle2D>>> onResizedProperty
    JavaScript window resize handler property. This handler is invoked when a script running on the Web page moves or resizes the `window` object.
    See Also:
      - `getOnResized()`
      - `setOnResized(EventHandler)`
      - `onResizedProperty()`

  - ### onVisibilityChanged

    public final ObjectProperty<EventHandler<WebEvent<Boolean>>> onVisibilityChangedProperty
    JavaScript window visibility handler property. This handler is invoked when a script running on the Web page changes visibility of the `window` object.
    See Also:
      - `getOnVisibilityChanged()`
      - `setOnVisibilityChanged(EventHandler)`
      - `onVisibilityChangedProperty()`

  - ### createPopupHandler

    public final ObjectProperty<Callback<PopupFeatures, WebEngine>> createPopupHandlerProperty
    JavaScript popup handler property. This handler is invoked when a script running on the Web page requests a popup to be created.

    To satisfy this request a handler may create a new `WebEngine`, attach a visibility handler and optionally a resize handler, and return the newly created engine. To block the popup, a handler should return `null`.

    By default, a popup handler is installed that opens popups in this `WebEngine`.

    See Also:
      - `getCreatePopupHandler()`
      - `setCreatePopupHandler(Callback)`
      - `createPopupHandlerProperty()`

  - ### confirmHandler

    public final ObjectProperty<Callback<String,Boolean>> confirmHandlerProperty
    JavaScript `confirm` handler property. This handler is invoked when a script running on the Web page calls the `confirm` function.

    An implementation may display a dialog box with Yes and No options, and return the user's choice.

    See Also:
      - `getConfirmHandler()`
      - `setConfirmHandler(Callback)`
      - `confirmHandlerProperty()`

  - ### promptHandler

    public final ObjectProperty<Callback<PromptData, String>> promptHandlerProperty
    JavaScript `prompt` handler property. This handler is invoked when a script running on the Web page calls the `prompt` function.

    An implementation may display a dialog box with an text field, and return the user's input.

    See Also:
      - `getPromptHandler()`
      - `setPromptHandler(Callback)`
      - `promptHandlerProperty()`

  - ### onError

    public final ObjectProperty<EventHandler<WebErrorEvent>> onErrorProperty
    The event handler called when an error occurs.
    Default value:
      `null`
    Since:
      JavaFX 8.0
    See Also:
      - `getOnError()`
      - `setOnError(EventHandler)`
      - `onErrorProperty()`

- ## Constructor Details

  - ### WebEngine

    public WebEngine()
    Creates a new engine.

  - ### WebEngine

    public WebEngine(String url)
    Creates a new engine and loads a Web page into it.
    Parameters:
      `url` - the URL of the web page to load

- ## Method Details

  - ### getLoadWorker

    public final Worker<Void> getLoadWorker()
    Returns a `Worker` object that can be used to track loading progress.
    Returns:
      the `Worker` object

  - ### getDocument

    public final Document getDocument()
    Gets the value of the `document` property.
    Property description:
      Document object for the current Web page. The value is `null` if the Web page failed to load.
    Returns:
      the value of the `document` property
    See Also:
      - `documentProperty()`

  - ### documentProperty

    public final ReadOnlyObjectProperty<Document> documentProperty()
    Document object for the current Web page. The value is `null` if the Web page failed to load.
    Returns:
      the document property
    See Also:
      - `getDocument()`

  - ### getLocation

    public final String getLocation()
    Gets the value of the `location` property.
    Property description:
      URL of the current Web page. If the current page has no URL, the value is an empty String.
    Returns:
      the value of the `location` property
    See Also:
      - `locationProperty()`

  - ### locationProperty

    public final ReadOnlyStringProperty locationProperty()
    URL of the current Web page. If the current page has no URL, the value is an empty String.
    Returns:
      the location property
    See Also:
      - `getLocation()`

  - ### getTitle

    public final String getTitle()
    Gets the value of the `title` property.
    Property description:
      Title of the current Web page. If the current page has no title, the value is `null`. This property will be updated asynchronously some time after the page is loaded. Applications should not rely on any particular timing, but should listen for changes to this property, or bind to it, to know when it has been updated.
    Returns:
      the value of the `title` property
    See Also:
      - `titleProperty()`

  - ### titleProperty

    public final ReadOnlyStringProperty titleProperty()
    Title of the current Web page. If the current page has no title, the value is `null`. This property will be updated asynchronously some time after the page is loaded. Applications should not rely on any particular timing, but should listen for changes to this property, or bind to it, to know when it has been updated.
    Returns:
      the title property
    See Also:
      - `getTitle()`

  - ### setJavaScriptEnabled

    public final void setJavaScriptEnabled(boolean value)
    Sets the value of the `javaScriptEnabled` property.
    Property description:
      Specifies whether JavaScript execution is enabled.
    Default value:
      true
    Parameters:
      `value` - the value for the `javaScriptEnabled` property
    Since:
      JavaFX 2.2
    See Also:
      - `isJavaScriptEnabled()`
      - `javaScriptEnabledProperty()`

  - ### isJavaScriptEnabled

    public final boolean isJavaScriptEnabled()
    Gets the value of the `javaScriptEnabled` property.
    Property description:
      Specifies whether JavaScript execution is enabled.
    Default value:
      true
    Returns:
      the value of the `javaScriptEnabled` property
    Since:
      JavaFX 2.2
    See Also:
      - `setJavaScriptEnabled(boolean)`
      - `javaScriptEnabledProperty()`

  - ### javaScriptEnabledProperty

    public final BooleanProperty javaScriptEnabledProperty()
    Specifies whether JavaScript execution is enabled.
    Default value:
      true
    Returns:
      the `javaScriptEnabled` property
    Since:
      JavaFX 2.2
    See Also:
      - `isJavaScriptEnabled()`
      - `setJavaScriptEnabled(boolean)`

  - ### setUserStyleSheetLocation

    public final void setUserStyleSheetLocation(String value)
    Sets the value of the `userStyleSheetLocation` property.
    Property description:
      Location of the user stylesheet as a string URL.

      This should be a local URL, i.e. either `'data:'`, `'file:'`, `'jar:'`, or `'jrt:'`. Remote URLs are not allowed for security reasons.

    Default value:
      null
    Parameters:
      `value` - the value for the `userStyleSheetLocation` property
    Since:
      JavaFX 2.2
    See Also:
      - `getUserStyleSheetLocation()`
      - `userStyleSheetLocationProperty()`

  - ### getUserStyleSheetLocation

    public final String getUserStyleSheetLocation()
    Gets the value of the `userStyleSheetLocation` property.
    Property description:
      Location of the user stylesheet as a string URL.

      This should be a local URL, i.e. either `'data:'`, `'file:'`, `'jar:'`, or `'jrt:'`. Remote URLs are not allowed for security reasons.

    Default value:
      null
    Returns:
      the value of the `userStyleSheetLocation` property
    Since:
      JavaFX 2.2
    See Also:
      - `setUserStyleSheetLocation(String)`
      - `userStyleSheetLocationProperty()`

  - ### userStyleSheetLocationProperty

    public final StringProperty userStyleSheetLocationProperty()
    Location of the user stylesheet as a string URL.

    This should be a local URL, i.e. either `'data:'`, `'file:'`, `'jar:'`, or `'jrt:'`. Remote URLs are not allowed for security reasons.

    Default value:
      null
    Returns:
      the `userStyleSheetLocation` property
    Since:
      JavaFX 2.2
    See Also:
      - `getUserStyleSheetLocation()`
      - `setUserStyleSheetLocation(String)`

  - ### getUserDataDirectory

    public final File getUserDataDirectory()
    Gets the value of the `userDataDirectory` property.
    Property description:
      Specifies the directory to be used by this `WebEngine` to store local user data.

      If the value of this property is not `null`, the `WebEngine` will attempt to store local user data in the respective directory. If the value of this property is `null`, the `WebEngine` will attempt to store local user data in an automatically selected system-dependent user- and application-specific directory.

      When a `WebEngine` is about to start loading a web page or executing a script for the first time, it checks whether it can actually use the directory specified by this property. If the check fails for some reason, the `WebEngine` invokes the `WebEngine.onError` event handler, if any, with a `WebErrorEvent` describing the reason. If the invoked event handler modifies the `userDataDirectory` property, the `WebEngine` retries with the new value as soon as the handler returns. If the handler does not modify the `userDataDirectory` property (which is the default), the `WebEngine` continues without local user data.

      Once the `WebEngine` has started loading a web page or executing a script, changes made to this property have no effect on where the `WebEngine` stores or will store local user data.

      Currently, the directory specified by this property is used only to store the data that backs the `window.localStorage` objects. In the future, more types of data can be added.

    Default value:
      `null`
    Returns:
      the value of the `userDataDirectory` property
    Since:
      JavaFX 8.0
    See Also:
      - `setUserDataDirectory(File)`
      - `userDataDirectoryProperty()`

  - ### setUserDataDirectory

    public final void setUserDataDirectory(File value)
    Sets the value of the `userDataDirectory` property.
    Property description:
      Specifies the directory to be used by this `WebEngine` to store local user data.

      If the value of this property is not `null`, the `WebEngine` will attempt to store local user data in the respective directory. If the value of this property is `null`, the `WebEngine` will attempt to store local user data in an automatically selected system-dependent user- and application-specific directory.

      When a `WebEngine` is about to start loading a web page or executing a script for the first time, it checks whether it can actually use the directory specified by this property. If the check fails for some reason, the `WebEngine` invokes the `WebEngine.onError` event handler, if any, with a `WebErrorEvent` describing the reason. If the invoked event handler modifies the `userDataDirectory` property, the `WebEngine` retries with the new value as soon as the handler returns. If the handler does not modify the `userDataDirectory` property (which is the default), the `WebEngine` continues without local user data.

      Once the `WebEngine` has started loading a web page or executing a script, changes made to this property have no effect on where the `WebEngine` stores or will store local user data.

      Currently, the directory specified by this property is used only to store the data that backs the `window.localStorage` objects. In the future, more types of data can be added.

    Default value:
      `null`
    Parameters:
      `value` - the value for the `userDataDirectory` property
    Since:
      JavaFX 8.0
    See Also:
      - `getUserDataDirectory()`
      - `userDataDirectoryProperty()`

  - ### userDataDirectoryProperty

    public final ObjectProperty<File> userDataDirectoryProperty()
    Specifies the directory to be used by this `WebEngine` to store local user data.

    If the value of this property is not `null`, the `WebEngine` will attempt to store local user data in the respective directory. If the value of this property is `null`, the `WebEngine` will attempt to store local user data in an automatically selected system-dependent user- and application-specific directory.

    When a `WebEngine` is about to start loading a web page or executing a script for the first time, it checks whether it can actually use the directory specified by this property. If the check fails for some reason, the `WebEngine` invokes the `WebEngine.onError` event handler, if any, with a `WebErrorEvent` describing the reason. If the invoked event handler modifies the `userDataDirectory` property, the `WebEngine` retries with the new value as soon as the handler returns. If the handler does not modify the `userDataDirectory` property (which is the default), the `WebEngine` continues without local user data.

    Once the `WebEngine` has started loading a web page or executing a script, changes made to this property have no effect on where the `WebEngine` stores or will store local user data.

    Currently, the directory specified by this property is used only to store the data that backs the `window.localStorage` objects. In the future, more types of data can be added.

    Default value:
      `null`
    Returns:
      the `userDataDirectory` property
    Since:
      JavaFX 8.0
    See Also:
      - `getUserDataDirectory()`
      - `setUserDataDirectory(File)`

  - ### setUserAgent

    public final void setUserAgent(String value)
    Sets the value of the `userAgent` property.
    Property description:
      Specifies user agent ID string. This string is the value of the `User-Agent` HTTP header.
    Default value:
      system dependent
    Parameters:
      `value` - the value for the `userAgent` property
    Since:
      JavaFX 8.0
    See Also:
      - `getUserAgent()`
      - `userAgentProperty()`

  - ### getUserAgent

    public final String getUserAgent()
    Gets the value of the `userAgent` property.
    Property description:
      Specifies user agent ID string. This string is the value of the `User-Agent` HTTP header.
    Default value:
      system dependent
    Returns:
      the value of the `userAgent` property
    Since:
      JavaFX 8.0
    See Also:
      - `setUserAgent(String)`
      - `userAgentProperty()`

  - ### userAgentProperty

    public final StringProperty userAgentProperty()
    Specifies user agent ID string. This string is the value of the `User-Agent` HTTP header.
    Default value:
      system dependent
    Returns:
      the `userAgent` property
    Since:
      JavaFX 8.0
    See Also:
      - `getUserAgent()`
      - `setUserAgent(String)`

  - ### getOnAlert

    public final EventHandler<WebEvent<String>> getOnAlert()
    Gets the value of the `onAlert` property.
    Property description:
      JavaScript `alert` handler property. This handler is invoked when a script running on the Web page calls the `alert` function.
    Returns:
      the value of the `onAlert` property
    See Also:
      - `setOnAlert(EventHandler)`
      - `onAlertProperty()`

  - ### setOnAlert

    public final void setOnAlert(EventHandler<WebEvent<String>> handler)
    Sets the value of the `onAlert` property.
    Property description:
      JavaScript `alert` handler property. This handler is invoked when a script running on the Web page calls the `alert` function.
    Parameters:
      `handler` - the value for the `onAlert` property
    See Also:
      - `getOnAlert()`
      - `onAlertProperty()`

  - ### onAlertProperty

    public final ObjectProperty<EventHandler<WebEvent<String>>> onAlertProperty()
    JavaScript `alert` handler property. This handler is invoked when a script running on the Web page calls the `alert` function.
    Returns:
      the onAlert property
    See Also:
      - `getOnAlert()`
      - `setOnAlert(EventHandler)`

  - ### getOnStatusChanged

    public final EventHandler<WebEvent<String>> getOnStatusChanged()
    Gets the value of the `onStatusChanged` property.
    Property description:
      JavaScript status handler property. This handler is invoked when a script running on the Web page sets `window.status` property.
    Returns:
      the value of the `onStatusChanged` property
    See Also:
      - `setOnStatusChanged(EventHandler)`
      - `onStatusChangedProperty()`

  - ### setOnStatusChanged

    public final void setOnStatusChanged(EventHandler<WebEvent<String>> handler)
    Sets the value of the `onStatusChanged` property.
    Property description:
      JavaScript status handler property. This handler is invoked when a script running on the Web page sets `window.status` property.
    Parameters:
      `handler` - the value for the `onStatusChanged` property
    See Also:
      - `getOnStatusChanged()`
      - `onStatusChangedProperty()`

  - ### onStatusChangedProperty

    public final ObjectProperty<EventHandler<WebEvent<String>>> onStatusChangedProperty()
    JavaScript status handler property. This handler is invoked when a script running on the Web page sets `window.status` property.
    Returns:
      the onStatusChanged property
    See Also:
      - `getOnStatusChanged()`
      - `setOnStatusChanged(EventHandler)`

  - ### getOnResized

    public final EventHandler<WebEvent<Rectangle2D>> getOnResized()
    Gets the value of the `onResized` property.
    Property description:
      JavaScript window resize handler property. This handler is invoked when a script running on the Web page moves or resizes the `window` object.
    Returns:
      the value of the `onResized` property
    See Also:
      - `setOnResized(EventHandler)`
      - `onResizedProperty()`

  - ### setOnResized

    public final void setOnResized(EventHandler<WebEvent<Rectangle2D>> handler)
    Sets the value of the `onResized` property.
    Property description:
      JavaScript window resize handler property. This handler is invoked when a script running on the Web page moves or resizes the `window` object.
    Parameters:
      `handler` - the value for the `onResized` property
    See Also:
      - `getOnResized()`
      - `onResizedProperty()`

  - ### onResizedProperty

    public final ObjectProperty<EventHandler<WebEvent<Rectangle2D>>> onResizedProperty()
    JavaScript window resize handler property. This handler is invoked when a script running on the Web page moves or resizes the `window` object.
    Returns:
      the onResized property
    See Also:
      - `getOnResized()`
      - `setOnResized(EventHandler)`

  - ### getOnVisibilityChanged

    public final EventHandler<WebEvent<Boolean>> getOnVisibilityChanged()
    Gets the value of the `onVisibilityChanged` property.
    Property description:
      JavaScript window visibility handler property. This handler is invoked when a script running on the Web page changes visibility of the `window` object.
    Returns:
      the value of the `onVisibilityChanged` property
    See Also:
      - `setOnVisibilityChanged(EventHandler)`
      - `onVisibilityChangedProperty()`

  - ### setOnVisibilityChanged

    public final void setOnVisibilityChanged(EventHandler<WebEvent<Boolean>> handler)
    Sets the value of the `onVisibilityChanged` property.
    Property description:
      JavaScript window visibility handler property. This handler is invoked when a script running on the Web page changes visibility of the `window` object.
    Parameters:
      `handler` - the value for the `onVisibilityChanged` property
    See Also:
      - `getOnVisibilityChanged()`
      - `onVisibilityChangedProperty()`

  - ### onVisibilityChangedProperty

    public final ObjectProperty<EventHandler<WebEvent<Boolean>>> onVisibilityChangedProperty()
    JavaScript window visibility handler property. This handler is invoked when a script running on the Web page changes visibility of the `window` object.
    Returns:
      the onVisibilityChanged property
    See Also:
      - `getOnVisibilityChanged()`
      - `setOnVisibilityChanged(EventHandler)`

  - ### getCreatePopupHandler

    public final Callback<PopupFeatures, WebEngine> getCreatePopupHandler()
    Gets the value of the `createPopupHandler` property.
    Property description:
      JavaScript popup handler property. This handler is invoked when a script running on the Web page requests a popup to be created.

      To satisfy this request a handler may create a new `WebEngine`, attach a visibility handler and optionally a resize handler, and return the newly created engine. To block the popup, a handler should return `null`.

      By default, a popup handler is installed that opens popups in this `WebEngine`.

    Returns:
      the value of the `createPopupHandler` property
    See Also:
      - `setCreatePopupHandler(Callback)`
      - `createPopupHandlerProperty()`

  - ### setCreatePopupHandler

    public final void setCreatePopupHandler(Callback<PopupFeatures, WebEngine> handler)
    Sets the value of the `createPopupHandler` property.
    Property description:
      JavaScript popup handler property. This handler is invoked when a script running on the Web page requests a popup to be created.

      To satisfy this request a handler may create a new `WebEngine`, attach a visibility handler and optionally a resize handler, and return the newly created engine. To block the popup, a handler should return `null`.

      By default, a popup handler is installed that opens popups in this `WebEngine`.

    Parameters:
      `handler` - the value for the `createPopupHandler` property
    See Also:
      - `getCreatePopupHandler()`
      - `createPopupHandlerProperty()`

  - ### createPopupHandlerProperty

    public final ObjectProperty<Callback<PopupFeatures, WebEngine>> createPopupHandlerProperty()
    JavaScript popup handler property. This handler is invoked when a script running on the Web page requests a popup to be created.

    To satisfy this request a handler may create a new `WebEngine`, attach a visibility handler and optionally a resize handler, and return the newly created engine. To block the popup, a handler should return `null`.

    By default, a popup handler is installed that opens popups in this `WebEngine`.

    Returns:
      the createPopupHandler property
    See Also:
      - `getCreatePopupHandler()`
      - `setCreatePopupHandler(Callback)`

  - ### getConfirmHandler

    public final Callback<String,Boolean> getConfirmHandler()
    Gets the value of the `confirmHandler` property.
    Property description:
      JavaScript `confirm` handler property. This handler is invoked when a script running on the Web page calls the `confirm` function.

      An implementation may display a dialog box with Yes and No options, and return the user's choice.

    Returns:
      the value of the `confirmHandler` property
    See Also:
      - `setConfirmHandler(Callback)`
      - `confirmHandlerProperty()`

  - ### setConfirmHandler

    public final void setConfirmHandler(Callback<String,Boolean> handler)
    Sets the value of the `confirmHandler` property.
    Property description:
      JavaScript `confirm` handler property. This handler is invoked when a script running on the Web page calls the `confirm` function.

      An implementation may display a dialog box with Yes and No options, and return the user's choice.

    Parameters:
      `handler` - the value for the `confirmHandler` property
    See Also:
      - `getConfirmHandler()`
      - `confirmHandlerProperty()`

  - ### confirmHandlerProperty

    public final ObjectProperty<Callback<String,Boolean>> confirmHandlerProperty()
    JavaScript `confirm` handler property. This handler is invoked when a script running on the Web page calls the `confirm` function.

    An implementation may display a dialog box with Yes and No options, and return the user's choice.

    Returns:
      the confirmHandler property
    See Also:
      - `getConfirmHandler()`
      - `setConfirmHandler(Callback)`

  - ### getPromptHandler

    public final Callback<PromptData, String> getPromptHandler()
    Gets the value of the `promptHandler` property.
    Property description:
      JavaScript `prompt` handler property. This handler is invoked when a script running on the Web page calls the `prompt` function.

      An implementation may display a dialog box with an text field, and return the user's input.

    Returns:
      the value of the `promptHandler` property
    See Also:
      - `setPromptHandler(Callback)`
      - `promptHandlerProperty()`

  - ### setPromptHandler

    public final void setPromptHandler(Callback<PromptData, String> handler)
    Sets the value of the `promptHandler` property.
    Property description:
      JavaScript `prompt` handler property. This handler is invoked when a script running on the Web page calls the `prompt` function.

      An implementation may display a dialog box with an text field, and return the user's input.

    Parameters:
      `handler` - the value for the `promptHandler` property
    See Also:
      - `getPromptHandler()`
      - `promptHandlerProperty()`

  - ### promptHandlerProperty

    public final ObjectProperty<Callback<PromptData, String>> promptHandlerProperty()
    JavaScript `prompt` handler property. This handler is invoked when a script running on the Web page calls the `prompt` function.

    An implementation may display a dialog box with an text field, and return the user's input.

    Returns:
      the promptHandler property
    See Also:
      - `getPromptHandler()`
      - `setPromptHandler(Callback)`

  - ### getOnError

    public final EventHandler<WebErrorEvent> getOnError()
    Gets the value of the `onError` property.
    Property description:
      The event handler called when an error occurs.
    Default value:
      `null`
    Returns:
      the value of the `onError` property
    Since:
      JavaFX 8.0
    See Also:
      - `setOnError(EventHandler)`
      - `onErrorProperty()`

  - ### setOnError

    public final void setOnError(EventHandler<WebErrorEvent> handler)
    Sets the value of the `onError` property.
    Property description:
      The event handler called when an error occurs.
    Default value:
      `null`
    Parameters:
      `handler` - the value for the `onError` property
    Since:
      JavaFX 8.0
    See Also:
      - `getOnError()`
      - `onErrorProperty()`

  - ### onErrorProperty

    public final ObjectProperty<EventHandler<WebErrorEvent>> onErrorProperty()
    The event handler called when an error occurs.
    Default value:
      `null`
    Returns:
      the `onError` property
    Since:
      JavaFX 8.0
    See Also:
      - `getOnError()`
      - `setOnError(EventHandler)`

  - ### load

    public void load(String url)
    Loads a Web page into this engine. This method starts asynchronous loading and returns immediately.
    Parameters:
      `url` - URL of the web page to load

  - ### loadContent

    public void loadContent(String content)
    Loads the given HTML content directly. This method is useful when you have an HTML String composed in memory, or loaded from some system which cannot be reached via a URL (for example, the HTML text may have come from a database). As with `load(String)`, this method is asynchronous.
    Parameters:
      `content` - the HTML content to load

  - ### loadContent

    public void loadContent(String content, String contentType)
    Loads the given content directly. This method is useful when you have content composed in memory, or loaded from some system which cannot be reached via a URL (for example, the SVG text may have come from a database). As with `load(String)`, this method is asynchronous. This method also allows you to specify the content type of the string being loaded, and so may optionally support other types besides just HTML.
    Parameters:
      `content` - the HTML content to load
      `contentType` - the type of content to load

  - ### reload

    public void reload()
    Reloads the current page, whether loaded from URL or directly from a String in one of the `loadContent` methods.

  - ### getHistory

    public WebHistory getHistory()
    Returns the session history object.
    Returns:
      history object
    Since:
      JavaFX 2.2

  - ### executeScript

    public Object executeScript(String script)
    Executes a script in the context of the current page.
    Parameters:
      `script` - the script
    Returns:
      execution result, converted to a Java object using the following rules:
      - JavaScript Int32 is converted to `java.lang.Integer`
      - Other JavaScript numbers to `java.lang.Double`
      - JavaScript string to `java.lang.String`
      - JavaScript boolean to `java.lang.Boolean`
      - JavaScript `null` to `null`
      - Most JavaScript objects get wrapped as `netscape.javascript.JSObject`
      - JavaScript JSNode objects get mapped to instances of `netscape.javascript.JSObject`, that also implement `org.w3c.dom.Node`
      - A special case is the JavaScript class `JavaRuntimeObject` which is used to wrap a Java object as a JavaScript value - in this case we just extract the original Java value.

  - ### print

    public void print(PrinterJob job)
    Prints the current Web page using the given printer job.

    This method does not modify the state of the job, nor does it call `PrinterJob.endJob()`, so the job may be safely reused afterwards.

    Parameters:
      `job` - printer job used for printing
    Since:
      JavaFX 8.0