这是我添加两个数字的简单javascript函数,这里这个函数在我的textfield上显示输出,其id为c,我想在新标签中显示输出
function add(){
var a = document.getElementById("num1").value;
a = parseInt(a);
var b = document.getElementById("num2").value;
b = parseInt(b);
var c = a+b;
document.getElementById("answer").value = c;
}
答案 0 :(得分:0)
您可以使用以下方式打开新标签页:
window.open("Your-URL-here","_BLANK");
答案 1 :(得分:0)
试试这段代码
function add(){
var a = document.getElementById("num1").value;
a = parseInt(a);
var b = document.getElementById("num2").value;
b = parseInt(b);
var c = a+b;
var w=window.open("")
w.document.write(c)
}

<input id="num1" type="number" />
<input id="num2" type="number" />
<input type="button" value="Add" onclick="add();return false" />
&#13;