Open a url in a new tab when user clicked a point in the plot

I’m trying to open a url in a new tab when user clicked a point in the plot. I followed this Plotly link. However, my js complained about the document elementid is null.

Thank you!