[英]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.