Open Method
Initializes the download request.
XAML |
Cannot use methods in XAML.
|
Scripting |
downloaderObject.Open(verb, uri)
|
verb | string The type of download action. The only supported action is "GET". |
uri | string The Uniform Resource Identifier (URI) of the content to perform the download action. |
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 subsequently call Send.
The uri you specify for Open must reference content on the same site of origin as the hosting HTML page. Cross-domain downloads are not permitted. Also, backslashes (\) in Downloader URIs are not permitted; always use forward slashes (/). Generally, a best practice is to use relative URIs, which are calculated based on the position of the hosting HTML page. For details, see Using a Downloader Object.
The following JavaScript example shows how to call the Open method:
JavaScript |
---|
// 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 or the following call will fail downloader.open("GET", "promo.png"); // Execute the Downloader request. downloader.send(); } |