将<button>
标签更改为<a>
标签
按钮没有href
标签具有的target
和<a>
属性。代码应如下所示:
function buildButton(url,i,size) {
document.write("Building Button with URL= "+url+"<p>");
var a = document.createElement("a");
a.appendChild(document.createTextNode("PIDs "+i+" to "+(i+size)));
a.setAttribute("href",url);
a.setAttribute("target","_blank");
document.body.appendChild(a);
}
buildButton('https://stackoverflow.com/',1,1);
<!DOCTYPE html>
<html>
<body>
</body>
</html>
,
通过以下方式解决:
GenScatterHierarchy<ScatterHierarchyTag<int,TYPELIST_3(int,string,Widget)>,Base>
,
基于此HTML button opening link in new tab的另一种解决方案。看来您还是想通了
function buildButton(url,size) {
document.write("Building Button with URL= "+url+"<p>");
var btn = document.createElement("button");
btn.appendChild(document.createTextNode("PIDs "+i+" to "+(i+size)));
btn.setAttribute("onclick","window.open('" +url+"','_blank')");
document.body.appendChild(btn);
}
buildButton("http://www.google.com","Thing",44) ;
本文链接:https://www.f2er.com/3126625.html