簡體   English   中英

如何使用 java 腳本打開帶有綁定參數的新選項卡

[英]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。 像這樣在此處輸入圖像描述


使用 window.open() 我可以打開 window 但我想將參數發送到新的 JSP。

而不是使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM