Configuring the virtual viewer Client by using JavaScript

You can use JavaScript to start the IBM Daeja ViewONE Virtual viewer. In this approach, the initial page that the user sees displays a list of documents to be viewed, but not a viewer. By using this approach, you can support different viewers for different documents or you can display multiple viewers on the same page to view multiple documents simultaneously. You can also provide quick viewing of individual documents in a tabbed interface.

About this task

With the HTML approach, the viewer detects the presence of the object tag within the HTML page and starts the viewer automatically. If you add the viewer by using JavaScript, the viewer does not start automatically. After you create the viewer object tags, you must call the following function with the ID viewone to start the viewer:
com.ibm.dv.client.Viewer.init('viewone');

If you do not call this function, the viewer does not run, and you have an empty object container on the screen and no viewer.

The following example illustrates the correct way to call this function:

function appendViewer1()
{
   var viewerCode = '<object class="com.ibm.dv.client.Viewer" id="viewone1" width="900" height="600">' +
                    '<param name="filename" Value=http://myserver/sample.tif?&path=docs/>' +
                    '</object>';
       
   document.getElementById('container').innerHTML = viewerCode;
                  
   com.ibm.dv.client.Viewer.init('viewone');
}

You can remove a viewer from a page by calling the following function:

com.ibm.dv.client.Viewer.destroy('viewone');

The following example demonstrates how to call the viewer to display four different documents: JPG, TIFF, JPG, and DOCX.

Procedure

  1. Edit the HTML page that displays the virtual viewer as shown in the examples.
  2. Verify that you can access the viewer by entering the URL to the HTML page in a browser.
    For example, enter the following URL: http://myserver:8080/viewone/viewone_virtual.html

What to do next

You can edit the HTML file later to customize the viewer to meet your requirements.