Click to return to the DHTML, HTML     
setHomePage Method     onbegin Event     Default Behaviors Referen...    
Web Workshop  |  DHTML, HTML & CSS

startDownload Method


Downloads the specified file.

Syntax

oDownload.startDownload (sUrl, fpCallback)

Parameters

sUrl Required. String that specifies the location of the file to download.
fpCallback Required. Function pointer that specifies the code to execute after the download is complete.

Return Value

No return value.

Remarks

The callback function pointer takes a single parameter. When a file downloads successfully, the file contents are passed as the parameter and are accessible in script.

The startDownload method returns only the content of text documents. If a different document format is downloaded, the format is returned, but the file content is not.

The following sample code shows a callback function.

// The callback function accepts one parameter.
function fnCallBack(vData){
   /* vData stores the downloaded file content.
      The content can be split into an array,
      written to another file, or processed in a form.
   */
   var aData=vData.split("\n");
}

Example

This example uses the startDownload method to begin downloading a file when the user clicks the link, and to notify the specified callback function, onDownloadDone, when the download is complete.

Sample Code

<HTML XMLNS:MSIE >

<MSIE:DOWNLOAD ID="oDownload" STYLE="behavior:url(#default#download)" />

<SCRIPT>
    function onDownloadDone(s) { alert (s); }
</SCRIPT>

<P>Click <A HREF="javascript:oDownload.startDownload('download.htm', 
onDownloadDone)">here</A> to download this page.
This feature requires Internet Explorer 5 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
download


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.