Launching applications from JavaScript

Problem

You have an application that you want to publish on your internal web site. You want to bypass the Tarantella webtop mechanism and launch the application when a user points their web browser at that page.

Solution

You can customize the way your applications are displayed by modifying whichever emulator applet page your application uses. You can use JavaScript to manipulate these applets. This allows you to create custom webtops or dispense with the webtop altogether and launch applications directly.

Alternatives
  • You can create a new webtop theme that automatically launches your application when a user logs in to Tarantella. Although this new theme does not bypass the Tarantella webtop, it can be configured to look and behave as if the application were being launched directly.

Case study

Indigo Insurance wants to use JavaScript to bypass the Tarantella webtop mechanism and launch a Microsoft PowerPoint presentation when a user points their web browser at that page. The standard X emulator page, xde.html, should display the application.

Solution

  1. On the same web server that provides access to Tarantella, in a directory that users can access from a web browser, create a new file called launch_my_app.html with the following content:
    <HTML>
    <HEAD>
    <TITLE>Indigo Insurance PowerPoint presentation</TITLE>
    
    <SCRIPT LANGUAGE="JavaScript">
    
    // Launch an application object. Arguments:
    // - object's TFN name in datastore.
    // - applet width in pixels.
    // - applet height in pixels.
    // - emulator applet page (usually xde.html or tde.html).
    //
    // Emulator applet pages assumed to be in 
    // $TTADIR/resources/webtops/
    
    function launch(object, width, height, applet_page)
       {
    
        // This is the page's URL.
        this_url="%%CGIPASSTHRU%%";
    
        // Check that it has been run through ttawebtop.cgi
        if (this_url.indexOf("ttawebtop.cgi") == -1)
           {
            document.write("Error - Must run through ttawebtop.cgi!");
            return;
           }
    
        // Get the Tarantella parts from the URL.
        a = this_url.split("/");
        loc = "";
        i = 3;
    
        while (a[i] != "cgi-bin")
           {
            loc += a[i]+"/";
            i++;
           }
        tta_url = a[0] + "//" + a[2] + "/" + loc + "cgi-bin/ttawebtop.cgi/" +
                  loc + "resources/webtops/" + applet_page;
    
        // Generate a timestamp based on the number of milliseconds since 
        // 1/1 1970 00:00:00.
        var date = new Date(); 
        var timestamp = Date.parse(date);
    
        // Build the final URL.
        url = tta_url + "?ob=" + object 
                      + "&aw=" + width
                      + "&ah=" + height
                      + "&ts=" + timestamp;
    	
        // Launch the application. Replace the current page.
        location.href = url;
    
       }
    
    </SCRIPT>
    
    </HEAD>
    
    <BODY>
    <p>Click the button to launch the PowerPoint presentation:</p>
    
    <FORM>
    <INPUT TYPE=button VALUE="Please click" 
    onclick='launch(".../_ens/o=Indigo Insurance/cn=ppt_pres", 
    640, 480, "sco/tta/standard/locale=en-us/tde.html")'>
    </FORM>
    
    </BODY>
    </HTML>

    This example web page invites the user to press a button. When they do, they are prompted for their Tarantella username and password (and their username and password for the application server, unless Tarantella has cached this information). They will then see the presentation.

  2. If you're using the Tarantella Security Pack (that is, you've installed the Tarantella Security Pack and turned security on), you'll need to change the value of AsadPort in xde.html from 3144 to 5307. You'll need to do this whether your users get standard or SSL connections.
  3. To launch the application, launch_my_app.html must be passed through the Tarantella CGI program ttawebtop.cgi manually, by using a URL of the form:
    http://server.indigo-insurance.com/tarantella/cgi-bin/ttawebtop.cgi/dest_dir/launch_my_app.html

    where dest_dir is the path to the web page on the web server. If the web page's URL was http://server.indigo-insurance.com/docs/launch_my_app.html for example, dest_dir would be docs.

    Launching the application object involves constructing the URL that Tarantella would use to launch the application from the webtop. In this example, launch_my_app.html employs JavaScript to parse the details of the ppt_pres Windows Application object and construct the URL. This process bypasses the Tarantella webtop mechanism and launches the application directly.

Next steps

Related topics
  • The ttawebtop.cgi CGI program