English

How To: Use hyperlinkPrefix and hyperlinkSuffix in the hyperlink-like function in Java Viewer

Summary

The "Customizing Java Viewer" PDF document, which is installed with ArcIMS, lists the steps for adding hyperlink-like functionality in an ArcIMS Java Viewer. This article includes additional information about using hyperlinkPrefix and hyperlinkSuffix variables, similar to the HTML Viewer's hyperlink functionality.

Procedure

For hyperlinks to work, the attributes for a layer must contain a field with valid URLs, for example, "http://www.esri.com". The hyperlinkPrefix and hyperlinkSuffix variables allow a developer to hard code the URL prefix and suffix. Using the example above, if hyperlinkPrefix = "http://www." and hyperlinkSuffix = ".com", then the layer's field value needs to contain a value of "esri".

Below are the steps for specifying hyperlinkPrefix and hyperlinkSuffix fields in an ArcIMS Java Viewer:

  1. Open frame.htm from <Drive>/ArcIMS/Website/<Website_Name> and add the highlighted lines of code as shown below:

    Code:
    <html>
    <head>
    <SCRIPT type=”text/javascript” language=”JavaScript”>
    // Designer will set the next variable - theTitle
    var theTitle = “San Francisco Museums”;
    if (theTitle.indexOf(“###TITLE##”)!=-1) theTitle = “ArcIMS Java Viewer”;
    document.writeln(“<TITLE>” + theTitle + “</TITLE>”);

    var hyperLinkLayers = new Array();
    var hyperLinkFields = new Array();
    var hyperLinkPrefix = new Array();
    var hyperLinkSuffix = new Array();

    hyperLinkLayers[0] = “museums”;
    hyperLinkFields[0] = “WEBSITE”
    hyperLinkPrefix[0]= "/gisdata/world/images/";
    hyperLinkSuffix[0] = ".jpg";

    </script>
    <script language=”javascript” src=”default.js”>
    </script>
    </head>

  2. Open toolbar.htm from <Drive>/ArcIMS/Website/<Website_Name> and make the changes as shown below:

    Code:
    if (parent.useShowSelect) {
    document.write(‘<td align=”center” valign=”middle”>’);
    // Choose between the following two calls.

    // The next line will display attributes of selected features in an HTML table; this is slower but can be customized easily.

    document.write(‘<img src=”images/attributes_1.gif” width=16 height=16 hspace=0
    vspace=1 border=0 alt=”Attributes” onmousedown=”showSelect(\’\’);”
    onmouseover=”window.status=\’Attributes\’”>’);

    // The next line will display attributes of selected features in a Java table; this is faster but cannot be customized.

    document.write(‘<img src=”images/attributes_1.gif” width=16 height=16
    hspace=0 vspace=1 border=0 alt=”Attributes” onmousedown=”displayAttributes(\’\’);”
    onmouseover=”window.status=\’Attributes\’”>’);


    isSecond = !isSecond;
    document.writeln(‘</td>’);
    if (isSecond) document.write(‘</tr><tr>’);
    }


  3. Open functions.js from <Drive>/ArcIMS/Website/<Website_Name> and find this line:

    function showSelect(returnString) {


    Within the showSelect function, add the highlighted line of code between the lines given below:

    Code:

    if (k > -1) {
    // Layer has hyperlink - check to see if this field is the one to use.
    if (theFields[j] == parent.hyperLinkFields[k]) {
    // This is the hyperlink field...use value as URL.

    thisValue=parent.hyperLinkPrefix[k]+ thisValue + parent.hyperLinkSuffix[k];

    sendValue = sendValue + "<a href='" + thisValue + "'>" + thisValue + "</a></font></td></tr>";
    }
    else {
    // This isn't the field to use for a hyperlink...just show data.
    sendValue = sendValue + thisValue + "</font></td></tr>";
    }

    Note:
    See "Using Hyperlinks" in the "Customizing Java Viewer" document for more information about hyperlink-like functionality in Java Viewer.