Created
May 6, 2020 17:01
-
-
Save AdamZWinter/7b272382c24f1a966d809248f9333aae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function openWindowWithPostRequest() { | |
var winName='MyWindow'; | |
var winURL='search.action'; | |
var windowoption='resizable=yes,height=600,width=800,location=0,menubar=0,scrollbars=1'; | |
var params = { 'param1' : '1','param2' :'2'}; | |
var form = document.createElement("form"); | |
form.setAttribute("method", "post"); | |
form.setAttribute("action", winURL); | |
form.setAttribute("target",winName); | |
for (var i in params) { | |
if (params.hasOwnProperty(i)) { | |
var input = document.createElement('input'); | |
input.type = 'hidden'; | |
input.name = i; | |
input.value = params[i]; | |
form.appendChild(input); | |
} | |
} | |
document.body.appendChild(form); | |
window.open('', winName,windowoption); | |
form.target = winName; | |
form.submit(); | |
document.body.removeChild(form); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment