The iuembed.js helper script is a special JavaScript that is used to embed File Downloader to the HTML page. This topic describes how to use this script.
In this topic:
You may wonder why to use a separate JavaScript file instead of using standard HTML means of inserting ActiveX controls? The main reason is that this approach lets you avoid the problem caused by the Internet Explorer security update 912945. This update causes all ActiveX controls inserted via the OBJECT tag to be "activated" by the user (with a mouse click or by pressing a key). This noticeably reduces usability. However, iuembed.js implements a workaround that allows avoiding this.
This script is used in the following way:
You can find iuembed.js in the root folder of the File Downloader SDK installation folder.
To be able to use iuembed.js, it is necessary to link it to your page. You can do it in the same way as you do with other JavaScript files, that is by using the SCRIPT tag with the src attribute set to the URL of iuembed.js.
In other words, you should insert the following string into the beginning of the HTML page (before any other JavaScript code):
<script type="text/javascript" src="iuembed.js"></script>
To embed File Downloader into a Web page, you need to do at least the following:
Here is a short example of adding File Downloader to a Web page:
<script type="text/javascript"> var fd = new FileDownloaderWriter("FileDownloader1", 122, 44); fd.writeHtml(); </script>
The FileDownloaderWriter constructor has three arguments: an ID of the control, a width, and a height. You can change these values later using appropriate properties.
Full list of FileDownloaderWriter members can be found at the end of this topic.
To initialize parameters of File Downloader you should use the addParam method of the FileDownloaderWriter class instance before calling writeHtml.
The addParam method takes two arguments: a name of the property and its value.
The following example should make it clear:
<script type="text/javascript"> var fd = new FileDownloaderWriter("FileDownloader1", 122, 44); fd.addParam("FileList", "http://localhost/filedownloader/filelist.txt"); fd.writeHtml(); </script>
It takes a while to download and install File Downloader. After download completes, the browser requires the user to click a button on the security dialog. Furthermore, if File Downloader is installed on Windows XP with Service Pack 2, the user should also click an information bar before the security dialog appears.
It may be quite confusing for the user. They may misunderstand installation instructions and reject installation when security dialog pops up.
In this case, displaying installation instructions is a good idea. iuembed.js exposes a number of properties that enable this.
The instructionsEnabled property specifies whether to display instructions or not. Set it to true to make instructions appear. The instructionsCommon property specifies an HTML code for those instructions which are common for all client platforms. The instructionsWinXPSP2 and instructionsNotWinXPSP2 values are appended to the common instructions depending on the client platform (Windows XP with Service Pack 2 or other platforms respectively).
This code snippet demonstrates how to use these properties:
fd.instructionsEnabled=true; fd.instructionsCommon="File Downloader ActiveX control is necessary to " + "download files quickly and easily. You will be able to select required " + "files in a user-friendly interface and simply click the \"Download\" " + "button. Installation will take up to few minutes, please be patient. To " + "install File Downloader, "; fd.instructionsNotWinXPSP2="please reload the page and click the \"Yes\" " + "button when you see the control installation dialog." fd.instructionsWinXPSP2="please click the Information Bar. After page reloads " + "click \"Yes\" when you see the control installation dialog.";
File Downloader provides a number of useful events which you can handle. To add event listeners do the following:
This example demonstrates how this should look like:
<script type="text/javascript"> function onError(Code, Description, HttpCode, Page, Url, Index){ //Your code } var fd = new FileDownloaderWriter("FileDownloader1", 122, 44); fd.addEventListener("Error", "onError"); </script>
See the full list of all FileDownloader events in the FileDownloader Events reference section.
The iuembed.js script contains a special function - getFileDownloader. It takes a single argument - the ID of the control, which you want to reference (for example, specified when creating an instance of FileDownloaderWriter), and returns a reference to the control.
Here is an example of obtaining a referenece:
var downloader = getFileDownloader("FileDownloader1");
Sometimes you need to modify File Downloader properties after initialization. The typical situation is when you need to change the file list in response to some user actions.
To do that, you should get a reference to the FileDownloader control as described above and modify the value of a required property.
The syntax of runtime property modification is the following:
object.setPropertyName(value), where PropertyName is a name of the property as specified in the FileDownloader Properties reference.
To read a property value, use object.getPropertyName instead.
The code snippet below shows how to work with properties after initialization:
var downloader = getFileDownloader("FileDownloader1"); downloader.setFileList(downloader.getFileList());
To call methods of FileDownloader, use the same approach as you use for properties: get a reference to the FileDownloader instance and call methods:
object.MethodName(argument1, argument2, ...), where MethodName is a name of the method as specified in the FileDownloader Methods reference.
Here is a code example:
var downloader = getFileDownloader("FileDownloader1"); downloader.DownloadFileList();
Quite often it is necessary to work with the File Downloader control when you are sure that the page has been fully loaded and the control itself has been completely created and initialized.
That is why iuembed.js exposes a special event, which is raised when the page is loaded, and the control is completely ready to be used. This event handler can be assigned to the fullPageLoadListenerName property of FileDownloaderWriter as follows:
<script language="javascript"> function onFullPageLoad(){ // ... Add necessary code ... } var fd = new FileDownloaderWriter("FileDownloader", 122, 44); fd.fullPageLoadListenerName = "onFullPageLoad"; // ... Configure File Downloader ... fd.writeHtml(); </script>
iuembed.js exposes only one class, FileDownloaderWriter, which corresponds to the only class of File Downloader, FileDownloader.
Name | Arguments | Description |
---|---|---|
![]() |
|
Adds a parameter with the specified name and value. The settings take effect when the writeHtml or getHtml method is run. |
![]() |
|
Subscribes the specified JavaScript function to the specified event. |
![]() |
N/A |
Verifies whether ActiveX control is installed. If yes, it returns true; otherwise it returns false. |
![]() |
N/A |
Generates the HTML code which will embed File Downloader and returns it as a string. It will write all parameters added with the addParam method and append all event handlers specified by the addEventListener method. |
![]() |
N/A |
Generates the HTML code, which will embed File Downloader, and writes this code directly into the page. It will write all parameters added with the addParam method and append all event handlers specified by the addEventListener method. |
Name | Default value | Description |
---|---|---|
![]() |
FileDownloader7.cab |
The URL that specifies where to download the ActiveX version of File Downloader from. It is an analogue of the codebase attribute of the <object> element. |
![]() |
FileDownloader7_x64.cab |
The URL that specifies where to download the 64-bit ActiveX version of File Downloader from. It is an analogue of the codebase attribute of the <object> element. |
![]() |
true |
Switch that specifies whether to use the ActiveX version of File Downloader. |
![]() |
empty string |
The minimum required version of the ActiveX version of File Downloader. |
![]() |
./ |
The URL that specifies the folder where to download the Java version of File Downloader from. |
![]() |
FileDownloader7.jar |
Name of the .jar file. |
![]() |
true |
Switch that specifies whether to use the Java version of File Downloader. |
![]() |
empty string |
The minimum required version of the Java version of File Downloader. |
![]() |
N/A (provided in the constructor) |
Height of the control. You should provide an integer number. Syntax like 100% is acceptable. |
![]() |
N/A (provided in the constructor) |
ID of the control that is used to get a reference with the help of the getFileDownloader function. |
![]() |
true |
Value that specifies whether to display instructionsCommon , instructionsNotWinXPSP2, and instructionsWinXPSP2 when File Downloader fails to be installed. |
![]() |
See code snippet above |
Common part of instructions displayed during download failure (regardless of the Windows version). Can contain any HTML code. |
![]() |
See code snippet above |
Part of instructions which is displayed if the current Windows is not Windows XP with Service Pack 2. Appended to the instructionsCommon string. Can contain any HTML code. |
![]() |
See code snippet above |
Part of instructions which is displayed if the current Windows is Windows XP with Service Pack 2. Appended to the instructionsCommon string. Can contain any HTML code. |
![]() |
N/A (provided in the constructor) |
Width of the control. You should provide an integer number. Syntax like 100% is acceptable. |
Name | Arguments | Description |
---|---|---|
![]() |
|
Returns a reference to the control with the specified ID. |
When private-label version is used, you need to customize the following properties (that should not be changed in the standard version):
Name | Description |
---|---|
![]() |
Name of the .cab file. |
![]() |
Name of the x64 .cab file. |
![]() |
CLSID of the ActiveX control. |
![]() |
PROGID of the ActiveX control. |
![]() |
Name of the .jar file. |
![]() |
Java applet class name. |
The following code snippet demonstrates how to use these properties:
<script type="text/javascript"> var fd = new FileDownloaderWriter("FileDownloader1", 122, 44); fd.activeXControlCodeBase = "MyDownloader.cab"; fd.activeXClassId = "B8144F57-C240-4012-A5AE-6E06019EDA5F"; fd.activeXProgId = "MyCompany.MyDownloader"; fd.javaAppletCodeBase = "MyDownloader.jar"; fd.writeHtml(); </script>