Compartir a través de


Open

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Initializes a download request.

downloaderObject.Open(verb, uri)

Arguments

verb

string

The type of download action. The only supported action is "GET".

uri

string

The Uniform Resource Identifier (URI) of the content to be downloaded.

Managed Equivalent

Managed programming does not use Downloader. See WebClient.

Remarks

The Open method initializes the Downloader object by specifying the action to perform and the content to perform the action on. However, the download is not committed until you call the Send method.

The uri parameter must reference content on the same site as the hosting HTML page. Cross-domain downloads are not permitted with the Downloader object. Also, backslashes (\) in Downloader URIs are not permitted; always use forward slashes (/). Generally, it is best to use relative URIs, which are calculated based on the position of the hosting HTML page.

Example

The following JavaScript example shows how to call the Open method.

// Event handler for initializing and executing a download request.
function onMouseLeftButtonUp(sender, eventArgs)
{
    // Retrieve a reference to the plug-in.
    var slPlugin = sender.getHost();

    // Create a Downloader object.
    var downloader = slPlugin.createObject("downloader");

    // Add DownloadProgressChanged and Completed events.
    downloader.addEventListener("downloadProgressChanged", onDownloadProgressChanged);
    downloader.addEventListener("completed", onCompleted);

    // Initialize the Downloader request.
    // Note: Downloader APIs disallow file:\\ scheme.
    // You must run this sample over localhost: or off a server; otherwise, the following call will fail.

    downloader.open("GET", "promo.png");

    // Execute the Downloader request.
    downloader.send();
}

Applies To

Downloader

See Also

Reference