[removed] sending custom parameters with window.open() but its not working

前端 未结 5 1616
一整个雨季
一整个雨季 2021-02-14 05:58




         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-14 06:39

    Please find this example code, You could use hidden form with POST to send data to that your URL like below:

    function open_win()
    {
        var ChatWindow_Height = 650;
        var ChatWindow_Width = 570;
    
        window.open("Live Chat", "chat", "height=" + ChatWindow_Height + ", width = " + ChatWindow_Width);
    
        //Hidden Form
        var form = document.createElement("form");
        form.setAttribute("method", "post");
        form.setAttribute("action", "http://localhost:8080/login");
        form.setAttribute("target", "chat");
    
        //Hidden Field
        var hiddenField1 = document.createElement("input");
        var hiddenField2 = document.createElement("input");
    
        //Login ID
        hiddenField1.setAttribute("type", "hidden");
        hiddenField1.setAttribute("id", "login");
        hiddenField1.setAttribute("name", "login");
        hiddenField1.setAttribute("value", "PreethiJain005");
    
        //Password
        hiddenField2.setAttribute("type", "hidden");
        hiddenField2.setAttribute("id", "pass");
        hiddenField2.setAttribute("name", "pass");
        hiddenField2.setAttribute("value", "Pass@word$");
    
        form.appendChild(hiddenField1);
        form.appendChild(hiddenField2);
    
        document.body.appendChild(form);
        form.submit();
    
    }
    

提交回复
热议问题