Skip past navigation linksSecure Global Desktop 4.31 Administration Guide > Applets > Launching applications from JavaScript

Launching applications from JavaScript

Problem

You have an application that you want to publish on your internal web site. You want to bypass the 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.

Note The Secure Global Desktop applets are only used with the classic webtop.

Alternatives

Case study

Indigo Insurance wants to use JavaScript to bypass the 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 Secure Global Desktop, in a directory that users can access from a web browser, create a new file called launch_my_app.html with the following content:
    Skip past command syntax or program code<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("...%2F_ens%2Fo%3DIndigo Insurance%2Fcn%3Dppt_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 Secure Global Desktop username and password (and their username and password for the application server, unless Secure Global Desktop has cached this information). They will then see the presentation.

  2. If you have enabled Secure Global Desktop security services, you will need to change the value of AsadPort in xde.html from 3144 to 5307. You 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 Secure Global Desktop CGI program ttawebtop.cgi manually, by using a URL of the form:
    Skip past command syntax or program codehttp://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 Secure Global Desktop 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 Webtop mechanism and launches the application directly.

Next steps

Related topics