我感觉很接近这一点。我只是无法生成要在新标签页中打开的按钮。我被卡住了!
function buildButton(url,i,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("href",url);
btn.setAttribute("target","_blank");
document.body.appendChild(btn);
}
答案 0 :(得分:1)
将<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>
答案 1 :(得分:0)
通过以下方式解决:
GenScatterHierarchy<ScatterHierarchyTag<int, TYPELIST_3(int,string,Widget)>, Base>
答案 2 :(得分:0)
基于此HTML button opening link in new tab的另一种解决方案。看来您还是想通了
function buildButton(url,i,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) ;