我需要在新选项卡或窗口中打开这些URL。现在他们正在同一页面中打开。d3.js window.open不适用于我
var data = [
{title: "1", url: "gallery1.html"},
{title: "2", url: "gallery2.html"},
{title: "3", url: "gallery3.html"},
];
.attr("xlink:href", function(d) { return d.example.url; })
.attr("xlink:title", function(d) { return d.example.title; });
svg.selectAll('.add-url-node')
.on('click',function(d){
location.href = 'target.url.com';
});
我尝试:
<script>
window.open(url);
</script>
和
window.open(link, "_blank")
和
data.forEach(function(elem){
window.open(elem.url,"_blank");
});
和
.attr("xlink:target", "_blank")
我没有编程经验,我真的很感激看到使用上面的代码的例子。非常感谢。
'window.open(d.url)'为我工作。 –
哪里?我试图说,而不是:location.href =“target.url.com”;它仍然在同一个标签中打开。 – kajihood
你检查过我的小提琴吗?它是否在同一个标签中打开? –