com.google.gwt.core.client

## Class ScriptInjector.FromUrl

- java.lang.Object
- - com.google.gwt.core.client.ScriptInjector.FromUrl

Enclosing class:
  ScriptInjector

    public static class ScriptInjector.FromUrl
    extends java.lang.Object

Build an injection call for adding a script by URL.

### Method Summary

All Methods Instance Methods Concrete Methods
`JavaScriptObject` `inject()` Injects an external JavaScript reference into the document and optionally calls a callback when it finishes loading.
`ScriptInjector.FromUrl` `setCallback(Callback<java.lang.Void,java.lang.Exception> callback)` Specify a callback to be invoked when the script is loaded or loading encounters an error.
`ScriptInjector.FromUrl` `setRemoveTag(boolean removeTag)`
`ScriptInjector.FromUrl` `setWindow(JavaScriptObject window)` This call allows you to specify which DOM window object to install the script tag in.

### Methods inherited from class java.lang.Object

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

### Method Detail

#### inject

    public JavaScriptObject inject()

Injects an external JavaScript reference into the document and optionally calls a callback when it finishes loading.

Returns:
  the script element created for the injection.

#### setCallback

    public ScriptInjector.FromUrl setCallback(Callback<java.lang.Void,java.lang.Exception> callback)

Specify a callback to be invoked when the script is loaded or loading encounters an error.

Warning: This class does not control whether or not a URL has already been injected into the document. The client of this class has the responsibility of keeping score of the injected JavaScript files.

Known bugs: This class uses the script tag's `onerror()` callback to attempt to invoke onFailure() if the browser detects a load failure. This is not reliable on all browsers (Doesn't work on IE or Safari 3 or less).

On Safari version 3 and prior, the onSuccess() callback may be invoked even when the load of a page fails.

To support failure notification on IE and older browsers, you should check some side effect of the script (such as a defined function) to see if loading the script worked and include timeout logic.

Parameters:
  `callback` - callback that gets invoked asynchronously.

#### setRemoveTag

    public ScriptInjector.FromUrl setRemoveTag(boolean removeTag)

Parameters:
  `removeTag` - If true, remove the tag after the script finishes loading. This shrinks the DOM, possibly at the expense of readability if you are debugging javaScript. Default value is `false`, but this may change in a future release.

#### setWindow

    public ScriptInjector.FromUrl setWindow(JavaScriptObject window)

This call allows you to specify which DOM window object to install the script tag in. To install into the Top level window call `builder.setWindow(ScriptInjector.TOP_WINDOW);`

Parameters:
  `window` - Specifies which window to install in.