File Downloader provides not many possibilities for customization. However, you can modify the control in the following ways:
By default, the download process begins after clicking on the Download button, which always has a standard look. If it does not fit your page, you may make any HTML button to start download; the following example shows how to perform it.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>file Downloader Polygon</title> <script type="text/javascript" src="iuembed.js"> </script> </head> <body> <script language="javascript"> var fd = new FileDownloaderWriter("FileDownloader1", 0, 0); fd.activeXControlCodeBase = "FileDownloader7.cab"; fd.activeXControlCodeBase64 = "FileDownloader7_x64.cab"; fd.activeXControlVersion = "7,0,1,0"; fd.javaAppletCodeBase = "./"; fd.javaAppletJarFileName = "FileDownloader7.jar"; fd.javaAppletVersion = "7.0.1.0"; fd.addParam("FileList", "http://localhost/filedownloader/filelist.txt"); fd.writeHtml(); </script> <script language="javascript"> function StartDownload() { var fd = getFileDownloader("FileDownloader1"); fd.Download(); } </script> <button type="button" style="background: #649FE9; color: #FFFFFF" onclick="StartDownload();"> Custom Download Button </button> </body> </html>
Here, we used the Download() method to start the download from the script.
You can not only replace the File Downloader button but also translate the whole user interface into another language. There are special properties that correspond to all text labels or caption that appear in the control, that is why each label can be translated.
Of course, you can add the translation by simply calling the addParam method of FileDownloaderWriter for each label. A complete list of all text properties can be found in the FileDownloader topic. But if you have a multilingual site, that allows fast switching between the languages, you can use another approach.
If you create a multilingual site that allows switching between differnet interface languages on the fly, you can use the following method.
var en_resources={use:function(id){ id.setFileExistsDialogTimeLeftText("Time left: [Current] of [Total]"); //...All other text entries }}
<html> <head> <title>File Downloader</title> <script type="text/javascript" src="iuembed.js"> </script> <!-- Link the translations --> <script type="text/javascript" src="en.js"> </script> <script type="text/javascript" src="fr.js"> </script> </head> <!-- ... --> </html>
<select id="SelectLanguage" onchange="translate();"> <option value="en" selected="true">[en] - English</option> <option value="fr">[fr] - French</option> </select>
<script language="javascript"> var loaded = false; function onFullPageLoad(){ if (loaded != true){ loaded = true; translate(); } } function translate(){ //Check if the page is fully loaded if (loaded){ var SelectLanguage = document.getElementById("SelectLanguage"); var language = SelectLanguage.options[SelectLanguage.selectedIndex].value; var expr = language+"_resources.use(getFileDownloader('FileDownloader'))"; eval(expr); } } //...Other code var fd = new FileDownloaderWriter("FileDownloader", 122, 44); fd.fullPageLoadListenerName = "onFullPageLoad"; fd.writeHtml(); </script>
You can use the Localization Sample as a base when translating File Downloader to your language.
When translating values of properties, you may notice that some of them contain words in brackets
like [Total]
, [Name]
, and so on. These are
placeholders that should not be translated. In runtime they will be replaced with the appropriate
values depending on the message displayed.
For example, when displaying the amount of time left before download finishes, the ProgressDialogDataAmountText property is used. This text is displayed in the progress dialog and by default has the value:
[Current] of [Total]
And when the user sees this text, it will already contain the corresponding value, say:
23,17 MB of 188,04 MB
See reference on the appropriate properties to learn more about the meaning of partucular placeholders.