Amending the infoTemplate to include links

1610
2
Jump to solution
01-22-2016 04:28 AM
OliviaGill1
New Contributor

Hi

I have an application with 3 feature layers and a select option. When the user clicks on a polygon for example the attributes for the related fields is returned. This is fine for attributes that are text based but I cannot figure out how to show a link within the infoTemplate rather than just the full string. e.g.

 var content = "<b>Classification year</b>: ${CLASSIFICATION_YEAR}" + "<br/>" +
            "<b>Overall classification</b>: ${OVERALL_CLASSIFICATION}" + "<br/>" +
            "<b>Link</b>: ${CLASS_DS_URL}";
          var infoTemplate = new InfoTemplate("${WATER_BODY_NAME}", content);

The class_ds_url shows the full string but how can I amend the script so it just has a clickable 'Link'??

Help is appreciated!

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi Olivia,

You can format the hyperlink using HTML.  Ex:

var content = "<b>Classification year</b>: ${CLASSIFICATION_YEAR}" + "<br/>" + 
            "<b>Overall classification</b>: ${OVERALL_CLASSIFICATION}" + "<br/>" + 
            "<b>Link</b>:  <a href=${CLASS_DS_URL}>Link</a>"; 
          
var infoTemplate = new InfoTemplate("${WATER_BODY_NAME}", content);

View solution in original post

2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Olivia,

You can format the hyperlink using HTML.  Ex:

var content = "<b>Classification year</b>: ${CLASSIFICATION_YEAR}" + "<br/>" + 
            "<b>Overall classification</b>: ${OVERALL_CLASSIFICATION}" + "<br/>" + 
            "<b>Link</b>:  <a href=${CLASS_DS_URL}>Link</a>"; 
          
var infoTemplate = new InfoTemplate("${WATER_BODY_NAME}", content);
OliviaGill1
New Contributor

Thank you - perfect!

0 Kudos