Open

Switch View :
ScriptFree
JavaScript API for Silverlight
Open

Initializes a download request.

JScript
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.

JScript
// 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

Community Content

Wolf Schmidt - MSFT
Re: useless
The Downloader API itself is restricting cross domain in this case, although a policy file might be in place too. That is a deliberate security decision/restriction in the API. For such file types as you might typically need (for instance images and media) there are separate APIs (SetSource) that DO NOT have this same domain restriction at the API level, BUT you still have to contend with the sender's policy, if any.

juergreh
useless
who wants to be restricted to load relative files only???? is there no other way to load files from different domains??? how about providing an alternative solution if a usefull feature like cross domain loading is disabled....drives me crazy

ahhh , so the cross domain policy file is doing the trick? why not mention this here and save me hours of browsing the web...