English

How To: Assign multiple hyperlinks to a feature in the HTML Viewer

Summary

Instructions provided describe how to assign multiple hyperlinks to a feature based on the hyperlink values from different fields. This article also expands upon the functionality described in the "Customizing HTML Viewer" ArcIMS documentation that explains the procedures to assign a single hyperlink to a feature in the HTML Viewer. The list of hyperlinks are displayed in the TextFrame.

Procedure

This article requires editing ArcIMSParam.js and displayAttributeData.htm files in the Web site, typically in <Drive>/ArcIMS/Website/<Website_Name> folder and aimsIdentify.js file in ArcIMS/Website/<Website_Name>/Javascript folder.

  • ArcIMS 4.0.1
    1. Create a hyperlink with a single hyperlink field, and verify it works properly. See "Creating hyperlinks" section, on page 26 of "Customizing HTML Viewer" for more descriptions.
    2. Open ArcIMSParam.js file from the Web site directory (For example: C:/ArcIMS/Website/<Website_Name>) in a text editor and look for this line:
    var hyperLinkLayers = new Array();
    Define hyperlink related varibles as shown below.
    Note:
    The same hyperlink layer can be defined muliple times with different hyperlink fields.
    hyperLinkLayers[0] = "layer1";
    hyperLinkFields[0] = "HLINK";
    hyperLinkPrefix[0] = "http://webservername/website/BitMaps/";
    hyperLinkSuffix[0] = "";
    hyperLinkLayers[1] = "layer1";
    hyperLinkFields[1] = "HLINK1";
    hyperLinkPrefix[1] = "http://webservername/website/";
    hyperLinkSuffix[1] = "";
    hyperLinkLayers[2] = "layer2";
    hyperLinkFields[2] = "LINK";
    hyperLinkPrefix[2] = "http://webservername/website/";
    hyperLinkSuffix[2] = "";
    
    3. Open aimsIdentify.js file in a text editor from <website_name>/javascript folder and locate this function:
    function hyperLink(e) {
    
    Change the function as follows:
    function hyperLink(e) {
    	if (checkIfActiveLayerAvailable()) {
    		if (currentHyperLinkLayer!="") {
    			highlightedOne="";
    			var theX = mouseX;
    			var theY = mouseY;
    			getMapXY(theX,theY);
    			searchTolerance = (xDistance/iWidth) * pixelTolerance;
    			var tempWest = mapX - searchTolerance;
    			var tempNorth = mapY + searchTolerance;
    			var tempEast = mapX + searchTolerance;
    			var tempSouth = mapY - searchTolerance;
    			var tempSwap = swapSelectFields;
    			swapSelectFields=false;
    			var tempSelect = selectFields;
    		var hyperlinkFlds = "";
    			for (var s1=0;s1<hyperLinkFields.length;s1++) {
    				if(LayerName[ActiveLayerIndex]==hyperLinkLayers[s1])
    					hyperlinkFlds += hyperLinkFields[s1] +" ";
    		}
    			selectFields = LayerIDField[ActiveLayerIndex] + " " + LayerShapeField[ActiveLayerIndex] + " " + hyperlinkFlds;
    			var theString = writeGetFeatures(tempWest,tempSouth,tempEast,tempNorth);
    			selectFields = tempSelect;
    			swapSelectFields=tempSwap;
    			showRetrieveData();
    			//if (useTextFrame) parent.TextFrame.document.location = "text.htm";
    			sendToServer(imsQueryURL,theString,hyperlinkXMLMode);
    		} else {
    			alert(msgList[47]);
    		}
    
    	}
    
    }
    4. In the same file, find the function:
    function parseHyperLink(theReply) { 
    Change the function as follows:
    function parseHyperLink(theReply) {
    	//alert(theReply);
    	var fList="";
    	var lpos1 = 1;
    	var lpos2 = 1;
    	var pos = 0;
    	var startpos = 0;
    	var endpos = 0;
    	var fString = theReply.substring(startpos,endpos);
    	var featureCount = justGetFeatureCount(theReply);
    	var linkString = "width=" + hyperlinkWindowWidth + ",height=" + hyperlinkWindowHeight + ",scrollbars=yes,resizable=yes"
    	var selectedData="";
    	var fCount = featureCount;
    	//alert("displayAttributeData()[featurecount=" + featureCount + "]");
    	selectCount = 0;
    	var tempString="";
    	var hString = "";
    	if (featureCount > 0) {
    
    	for (var s1=0;s1<hyperLinkFields.length;s1++) {
    		if(LayerName[ActiveLayerIndex]==hyperLinkLayers[s1]){
    
    			var searchStr = hyperLinkFields[s1] + "=";
    			//alert(searchStr);
    			newSelectCount += 1;
    
    			endpos = 1;
    			pos = theReply.indexOf(searchStr,1);
    		if (pos>-1){
    				startpos = pos + searchStr.length + 1;
    				endpos =theReply.indexOf(dQuote,startpos);
    				inData = theReply.substring(startpos,endpos);
    				var theLinkURL = hyperLinkPrefix[s1] + inData + hyperLinkSuffix[s1];
    				//var Win1=open(theLinkURL,"",linkString);
    				hString += '<BR><b>' + hyperLinkFields[s1] + '</b> : <a href="' + theLinkURL + '" target="_blank">'+ theLinkURL + '</a>';
    			   }
    			}
    
    		}
    		var hresult = '<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>';
    		hresult += ' <title>' + titleList[9] + 's</title>';
    		hresult += '</head>';
    		hresult += '<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>';
    		hresult += '<FONT FACE="Arial"><B>' + LayerName[ActiveLayerIndex] +'</B></font><FONT FACE="Arial" size="-2">';
    		hresult += hString;
    		hresult += '</FONT>';
    		hresult += '</body></html>';
    	if (parent.TextFrame!=null) {
    			Win1 = parent.TextFrame;
    			Win1.document.open();
    	} else {
    			Win1 = open("","DataWindow","width=575,height=250,scrollbars=yes,resizable=yes");
    			extWin = Win1;
    			focusOnData = true;
    	}
    		Win1.document.writeln(hresult);
    		Win1.document.close();
    	} else {
    		//alert(tempString);
    		if (parent.TextFrame!=null) {
    			parent.TextFrame.document.open();
    			parent.TextFrame.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
    			parent.TextFrame.document.writeln(' <title>' + titleList[9] + '</title>');
    			parent.TextFrame.document.writeln('</head>');
    			parent.TextFrame.document.writeln('<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>');
    			parent.TextFrame.document.writeln('<FONT FACE="Arial"><B>' + LayerName[ActiveLayerIndex] +'</B></font><FONT FACE="Arial" size="-2">');
    			parent.TextFrame.document.writeln('<br>' + msgList[68]);
    			if (debugOn>0) {
    				parent.TextFrame.document.writeln('<p>' + msgList[65] + '<br>');
    				parent.TextFrame.document.writeln(untag(theReply));
    			}
    			parent.TextFrame.document.writeln('</FONT>');
    			parent.TextFrame.document.writeln('</body></html>');
    			parent.TextFrame.document.close();
    		} else {
    			var msg = msgList[69];
    			if (debugOn>0) {
    				msg = msg + msgList[9] + theReply;
    			}
    			alert(msg);
    		}
    	}
    	hideRetrieveData();
    }
    Save the file.
    5. Open displayAttributeData.htm file from ArcIMS/website/<website_name> folder in a text editor and locate the code:
    if (showHyper) {
    	for (var s1=0;s1<t_id.hyperLinkFields.length;s1++) {
    		if (t_id.hyperLinkFields[s1]==fName1[f]) {
    			var theLinkURL = t_id.hyperLinkPrefix[s1] + fValue1[f] + t_id.hyperLinkSuffix[s1];
    			document.write('<a href="' + theLinkURL + '" target="_blank">');
    			isHyper=true;
    		} 
    	}
    }
    
    Modify the code as follows:
    if (showHyper) {
    	for (var s1=0;s1<t_id.hyperLinkFields.length;s1++) {
            	if(t_id.LayerName[t_id.ActiveLayerIndex]==t_id.hyperLinkLayers[s1]){ 
    			if (t_id.hyperLinkFields[s1]==fName1[f]) {
    				var theLinkURL = t_id.hyperLinkPrefix[s1] + fValue1[f] + t_id.hyperLinkSuffix[s1];
    				document.write('<a href="' + theLinkURL + '" target="_blank">');
    				isHyper=true;
                            	break;
    	 		}
            	}  
    	}
    } 
    
    • ArcIMS 9.x
      1. Create a hyperlink with a single hyperlink field, and verify it works properly. See "Creating hyperlinks" section, on page 26 of "Customizing HTML Viewer" for more descriptions.
      2. Open ArcIMSParam.js file from the Web site directory (For example: C:/ArcIMS/Website/<Website_Name>) in a text editor and look for this line:
      var hyperLinkLayers = new Array();
      Define hyperlink related varibles as shown below.
      Note:
      The same hyperlink layer can be defined muliple times with different hyperlink fields.
      hyperLinkLayers[0] = "layer1";
      hyperLinkFields[0] = "HLINK";
      hyperLinkPrefix[0] = "http://webservername/website/BitMaps/";
      hyperLinkSuffix[0] = "";
      hyperLinkLayers[1] = "layer1";
      hyperLinkFields[1] = "HLINK1";
      hyperLinkPrefix[1] = "http://webservername/website/";
      hyperLinkSuffix[1] = "";
      hyperLinkLayers[2] = "layer2";
      hyperLinkFields[2] = "LINK";
      hyperLinkPrefix[2] = "http://webservername/website/";
      hyperLinkSuffix[2] = "";
      
      3. Open aimsIdentify.js file in a text editor from <website_name>/javascript folder and locate this function:
      function hyperLink(e) {
      
      Change the function as follows:
      function hyperLink(e) {
      	if (checkIfActiveLayerAvailable()) {
      		if (currentHyperLinkLayer!="") {
      			highlightedOne="";
      			var theX = mouseX;
      			var theY = mouseY;
      			getMapXY(theX,theY);
      			searchTolerance = (xDistance/iWidth) * pixelTolerance;
      			var tempWest = mapX - searchTolerance;
      			var tempNorth = mapY + searchTolerance;
      			var tempEast = mapX + searchTolerance;
      			var tempSouth = mapY - searchTolerance;
      			var tempSwap = swapSelectFields;
      			swapSelectFields=false;
      			var tempSelect = selectFields;
      		var hyperlinkFlds = "";
      			for (var s1=0;s1<hyperLinkFields.length;s1++) {
      				if(LayerName[ActiveLayerIndex]==hyperLinkLayers[s1])
      					hyperlinkFlds += hyperLinkFields[s1] +" ";
      		}
      			selectFields = LayerIDField[ActiveLayerIndex] + " " + LayerShapeField[ActiveLayerIndex] + " " + hyperlinkFlds;
      			var theString = writeGetFeatures(tempWest,tempSouth,tempEast,tempNorth);
      			selectFields = tempSelect;
      			swapSelectFields=tempSwap;
      			showRetrieveData();
      			//if (useTextFrame) parent.TextFrame.document.location = "text.htm";
      			sendToServer(imsQueryURL,theString,hyperlinkXMLMode);
      		} else {
      			alert(msgList[47]);
      		}
      	}
      }
      4. In the same file, find the function:
      function parseHyperLink(theReply) { 
      Change the function as follows:
      function parseHyperLink(theReply) {
      	//alert(theReply);
      	var fList="";
      	var lpos1 = 1;
      	var lpos2 = 1;
      	var pos = 0;
      	var startpos = 0;
      	var endpos = 0;
      	var fString = theReply.substring(startpos,endpos);
      	var featureCount = justGetFeatureCount(theReply);
      	var linkString = "width=" + hyperlinkWindowWidth + ",height=" + hyperlinkWindowHeight + ",scrollbars=yes,resizable=yes"
      	var selectedData="";
      	var fCount = featureCount;
      	//alert("displayAttributeData()[featurecount=" + featureCount + "]");
      	selectCount = 0;
      	var tempString="";
      	var hString = "";
      	if (featureCount > 0) {
      
      	for (var s1=0;s1<hyperLinkFields.length;s1++) {
      		if(LayerName[ActiveLayerIndex]==hyperLinkLayers[s1]){
      
      			var searchStr = hyperLinkFields[s1] + "=";
      			//alert(searchStr);
      			newSelectCount += 1;
      
      			endpos = 1;
      			pos = theReply.indexOf(searchStr,1);
      			if (pos>-1){
      					startpos = pos + searchStr.length + 1;
      					endpos =theReply.indexOf(dQuote,startpos);
      					inData = theReply.substring(startpos,endpos);
      					var theLinkURL = hyperLinkPrefix[s1] + inData + hyperLinkSuffix[s1];
      					//var Win1=open(theLinkURL,"",linkString);
      					hString += '<BR><b>' + hyperLinkFields[s1] + '</b> : <a href="' + theLinkURL + '" target="_blank">'+ theLinkURL + '</a>';
      				}
      			}
      		}
      		var hresult = '<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>';
      		hresult += ' <title>' + titleList[9] + 's</title>';
      		hresult += '</head>';
      		hresult += '<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>';
      		hresult += '<FONT FACE="Arial"><B>' + LayerName[ActiveLayerIndex] +'</B></font><FONT FACE="Arial" size="-2">';
      		hresult += hString;
      		hresult += '</FONT>';
      		hresult += '</body></html>';
      	if (parent.TextFrame!=null) {
      			Win1 = parent.TextFrame;
      			Win1.document.open();
      	} else {
      			Win1 = open("","DataWindow","width=575,height=250,scrollbars=yes,resizable=yes");
      			extWin = Win1;
      			focusOnData = true;
      	}
      		Win1.document.writeln(hresult);
      		Win1.document.close();
      	} else {
      		//alert(tempString);
      		if (parent.TextFrame!=null) {
      			parent.TextFrame.document.open();
      			parent.TextFrame.document.writeln('<html><meta http-equiv="Content-Type" content="text/html; charset=' + charSet + '"><head>');
      			parent.TextFrame.document.writeln(' <title>' + titleList[9] + '</title>');
      			parent.TextFrame.document.writeln('</head>');
      			parent.TextFrame.document.writeln('<body BGCOLOR="White" TEXT="Black" LEFTMARGIN=0 TOPMARGIN=0>');
      			parent.TextFrame.document.writeln('<FONT FACE="Arial"><B>' + LayerName[ActiveLayerIndex] +'</B></font><FONT FACE="Arial" size="-2">');
      			parent.TextFrame.document.writeln('<br>' + msgList[68]);
      			if (debugOn>0) {
      				parent.TextFrame.document.writeln('' + msgList[65] + '<br>');
      				parent.TextFrame.document.writeln(untag(theReply));
      			}
      			parent.TextFrame.document.writeln('</FONT>');
      			parent.TextFrame.document.writeln('</body></html>');
      			parent.TextFrame.document.close();
      		} else {
      			var msg = msgList[69];
      			if (debugOn>0) {
      				msg = msg + msgList[9] + theReply;
      			}
      			alert(msg);
      		}
      	}
      	hideRetrieveData();
      }
      Save the file.