[英]How to open a new Tab with bind parameters using java script
这是我的 function。 我想用下面的 URL 打开一个新的 window 并传递这些参数。
function viewWeightAge() {
var userNIC = document.getElementById("NICNo");
var childName = document.getElementById("childName");
window.location.href = "https://localhost:8080/KiddieCare/AdminPanel/WeightAgeGraph.jsp?childName="+childName+"&userNIC="+userNIC;
}
谁能解释我的错误?
问题已更新。
function showWeightAge(){
var userNIC = document.getElementById("NICNo");
var childName = document.getElementById("childName");
var parameters= userNIC,childName;
window.open ('https://localhost:8080/KiddieCare/AdminPanel/WeightAgeGraph.jsp','Window Name',parameters);
}
而不是使用window.location.href
更改当前 window 的 url
你应该使用window.open()
https://www.w3schools.com/jsref/met_win_open.asp
请注意,它可能会被阻止为不需要的弹出窗口
在您的情况下,可以这样做
function viewWeightAge() {
const userNIC = document.getElementById("NICNo");
const childName = document.getElementById("childName");
window.open("https://localhost:8080/KiddieCare/AdminPanel/WeightAgeGraph.jsp?childName="+childName+"&userNIC="+userNIC);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.