Forum Discussion
Hyperlink not clickable with custom visual.
Hello,
I am working on creating custom visual which creats simple hyperlink using d3js.
Some how when its clicked it dosent open the browser even though the link has proper href and target tags.
I also tried by giving the column appropriate Data Category of Web Url.
Is this due to any security reasons?
Isnt that possible in custom visual?
9 Replies
- LuisaNew Member
For anyone still searching for the answer to this (as I was), there is a utility in Power BI to do this called Launch URL. You can use it as simply as follows.
.on("click", data => {(d3.event as MouseEvent).preventDefault();});Here are the docs about it:
https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/LaunchURL.md
- vincent_1234Helper I
It is because of sandboxed iframes are blocking this behavior
When clicking hyperlink:
Blocked opening url in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.
When embedding in iframe:
Refused to display url in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
- dhavaluFrequent Visitor
Hey Vincent, Thanks for the reply.
Is there any alternative to this. How come the exiting table control render link tag when the column is "Web Url"? Any Idea?
Thanks.
- vincent_1234Helper I
I have not found any alternative.
Native visuals can use urls because they are not sandboxed in iframes.
I understand Microsoft does this for safety so improper developed custom visuals can't collide but it would be nice if we wern't limited in functionality.
- SreejithAdvocate I
The following code worked for me while trying to create a custom visual that have a Resolve link which redirects to an API on click. I used the default YourVisual template and added the link as
tr.selectAll("td")
.data(d=> d)
.enter().append("td")
.attr('data-th',(d, i) => viewModel.categories[i].value)
.text(d => this.format(d)).append('a')
.attr("href", "https://www.google.com")
.attr("target","_top")
.text(" Resolve");Hope this helps.
- vincent_1234Helper I
This doesn't work for me (either _top or _blank) in both designer and portal