在JS中模擬表單的post提交,進行頁面的跳轉


原文鏈接:https://blog.csdn.net/jal517486222/article/details/83147761

 

 /*
*功能: 模擬form表單的提交
*參數: URL 跳轉地址 PARAMTERS 參數
*/
     function Post(URL, PARAMTERS) {
         //創建form表單
         var temp_form = document.createElement("form");
         temp_form.action = URL;
         //如需打開新窗口,form的target屬性要設置為'_blank'
         temp_form.target = "_self";
         temp_form.method = "post";
         temp_form.style.display = "none";
         //添加參數
         for (var item in PARAMTERS) {
             var opt = document.createElement("textarea");
             opt.name = item;
             opt.value = PARAMTERS[item];
             temp_form.appendChild(opt);
         }
         document.body.appendChild(temp_form);
         //提交數據
         temp_form.submit();
     }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM