Spec-Zone .ru
спецификации, руководства, описания, API
|
public final class HostServices
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCodeBase()
Gets the code base URI for this application.
|
java.lang.String |
getDocumentBase()
Gets the document base URI for this application.
|
JSObject |
getWebContext()
Returns the JavaScript handle of the enclosing DOM window of the web
page containing this application.
|
java.lang.String |
resolveURI(java.lang.String base,
java.lang.String rel)
Resolves the specified relative URI against the base URI and returns
the resolved URI.
|
void |
showDocument(java.lang.String uri)
Opens the specified URI in a new browser window or tab.
|
public final java.lang.String getCodeBase()
public final java.lang.String getDocumentBase()
public final java.lang.String resolveURI(java.lang.String base, java.lang.String rel)
Example:
HostServices services = getHostServices(); String myImage = services.resolveURI(services.getDocumentBase(), "image.jpg"); Image image = new Image(myImage);
base
- the base URI against which to resolve the relative URIrel
- the relative URI to be resolvedjava.lang.NullPointerException
- if either the base
or the
rel
strings are null.java.lang.IllegalArgumentException
- if there is an error parsing either
the base
or rel
URI strings, or if there is
any other error in resolving the URI.public final void showDocument(java.lang.String uri)
uri
- the URI of the web page that will be opened in a browser.public final JSObject getWebContext()
Example:
JSObject jsWin = getHostServices().getWebContext(); if (jsWin != null) { jsWin.eval("var b = document.body;" + "var newdiv = document.createElement('div');" + "newdiv.innerHTML = '<br>Hello from JavaScript!';" + "b.appendChild(newdiv);"); }
Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to