Set hyperlink in InfoTemplate by field in attribute table

2980
3
08-12-2015 11:39 AM
AshleyPeters
Occasional Contributor III

I have a field in my attribute table that contains a link to a web page. In Flex, I was able to create a hyperlink using this field to populate the appropriate place in my popup. I'd like to do the same now with JavaScript.

I have the InfoTemplate set up and it looks perfect. However, when I click on the link, a new browser page is opened, but it does not go to the link contained in my attribute table. Instead, it is opening a new page of the project I'm working on. How do I need to rewrite the href section of this code for the link to work?

Thanks in advance for your help!

Here's my code:

var stateParksInfoTemplate = new InfoTemplate();
stateParksInfoTemplate.setTitle("<b>${NAME}</b>");

var stateParksInfoContent =
"<div class=\"InfoContent\">" +
"For more information on <b>${NAME}</b>, please <a href='${LINK}' target='_blank'><font color='0x84CCDA'>click here</font></a>."
+ "</div>";

stateParksInfoTemplate.setContent(stateParksInfoContent);

0 Kudos
3 Replies
ChrisSmith7
Frequent Contributor

Ashley,

This came-up a few times in the past - it seems to be a common question! I had issues with links myself before... Have a look at the following threads - they may have some info to help you:

additional function in infotemplate hyperlink

InfoWindow fields - URLs automatically add "_blank" as target

AshleyPeters
Occasional Contributor III

Thanks Chris,

I've got it working now. I had a capitalization issue, LINK should have been Link.

Ashley

ChrisSmith7
Frequent Contributor

Cool - easy fix!

0 Kudos