繁体   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