I have 2 arrays of <a> tags, one has an href attribute, and the other has an onclick attribute. When the <a> arrays are carried into the popupTemplate, it always clears all the attributes but keeps the text within <a></a>, rendering the link unusable or incorrect.
Solved! Go to Solution.
Have you seen this thread? You'll find various proposed solutions to this kind of problem there.
Can you post your code?
Here are some snippets of the relevant pieces of code:
What are you expecting when someone clicks on "Test"? If it's opening up another site, then this works (using this sample)
var linkArray = [
"<a href='http://google.com'>Test</a>",
]
const polylineGraphic = new Graphic({
geometry: polyline,
symbol: lineSymbol,
attributes: lineAtt,
popupTemplate: {
// autocasts as new PopupTemplate()
title: "{Name}",
content: linkArray[0]
}
});
So the links I am grabbing from an underlying webpage, has links that look like(which is supposed to get copy and pasted into the popupbox):
<a href='' onclick='alert()'>Test</a>
^This one is supposed to open an alert() dialogue box in the browser.
<a href='javascript:linkTest();'>Test</a> (: is supposed to just be a normal colon but the forum is changing it to :)
^This one is supposed to bring a user to a new website using a javascript function, as it returns a link that is dynamically generated
The main issue that I am having, is that it seems to remove all of the attributes, if it isn't a normal link like what you did above.
by what I mean by "copy and pasted", I grabbed all the links and stored them into an array, to be displayed into the popupBox
Have you seen this thread? You'll find various proposed solutions to this kind of problem there.
Thanks for the pointer! I swear I was looking everywhere up and down, but I just wasn't using the right phrasing. This immediately helped!