|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.gwt.core.client.ScriptInjector
public class ScriptInjector
Dynamically create a script tag and attach it to the DOM. Usage with script as local string:
String scriptBody = "var foo = ..."; ScriptInjector.fromString(scriptBody).inject();
Usage with script loaded as URL:
ScriptInjector.fromUrl("http://example.com/foo.js").setCallback( new Callback() { public void onFailure(Exception reason) { Window.alert("Script load failed."); } public void onSuccess(Void result) { Window.alert("Script load success."); } }).inject();
Nested Class Summary | |
---|---|
static class |
ScriptInjector.FromString
Builder for directly injecting a script body into the DOM. |
static class |
ScriptInjector.FromUrl
Build an injection call for adding a script by URL. |
Field Summary | |
---|---|
static JavaScriptObject |
TOP_WINDOW
Returns the top level window object. |
Method Summary | |
---|---|
static ScriptInjector.FromString |
fromString(java.lang.String scriptBody)
Build an injection call for directly setting the script text in the DOM. |
static ScriptInjector.FromUrl |
fromUrl(java.lang.String scriptUrl)
Build an injection call for adding a script by URL. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final JavaScriptObject TOP_WINDOW
$wnd
in JSNI
access.
Note that if your GWT app is loaded from a different domain than the top window, you may not be able to add a script element to the top window.
Method Detail |
---|
public static ScriptInjector.FromString fromString(java.lang.String scriptBody)
scriptBody
- the script text to be injected and immediately executed.public static ScriptInjector.FromUrl fromUrl(java.lang.String scriptUrl)
scriptUrl
- URL of the JavaScript to be injected.
|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |