Eugene S
Eugene S

Reputation: 3122

Highstock Chart with URL in flag text won't open in new window

I have a Highstock chart set up with flags marking events. In the text attribute of the flag I have an anchor HTML element with the target property set to _blank, however when I click the link, the page is opened in the current page/tab as opposed to a new page/tab.

Can someone from the Highcharts team confirm if this use case is supported?

An example flag element:

{
    x : Date.UTC(2014,0,21),
    title : '3',
    text : '<a href="http://www.alwaysorderdessert.com/2014/01/brussels-sprouts-salad-with-pecorino.html" target="_blank">Brussels Sprouts Salad with Pecorino, Hazelnuts & Honey</a>'
}

Thanks!

Upvotes: 0

Views: 372

Answers (1)

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

It is not opened, becasue html element is parsed to SVG object. You need to catch click event and use window.open()

 plotOptions: {
            flags: {
                point: {
                    events: {
                        click: function (e) {
                            e.preventDefault();
                            var url = this.url;
                            window.open(url, '_blank');
                        }
                    }
                }
            }
        },

http://jsfiddle.net/7AegD/3/

Upvotes: 1

Related Questions