Monthly Archives: January 2018

window.open 변수넘길때, post방식으로 하기

 

1) GET방식

/* get */
window.open(URL + "&" + encodeURI($.param(params, true)), "popup_id", 'height=' + 650  + ',width=' + 1024 + 'fullscreen=yes');

 

2) POST방식

/* post */
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", url);
form.setAttribute("target", "popup_id");

var input = document.createElement('input');
input.type = 'hidden';
input.name = "변수1";
input.value = "변수값1";
form.appendChild(input);

input = document.createElement('input');
input.type = 'hidden';
input.name = "변수2";
input.value = "변수값2";
form.appendChild(input);

input = document.createElement('input');
input.type = 'hidden';
input.name = "변수3";
input.value = "변수값3";
form.appendChild(input);

document.body.appendChild(form);

if( /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor) ){
	window.open(url, "popup_id");
}else{
	window.open(url, "popup_id", "resizable=yes,toolbar=yes,menubar=yes,location=yes");
}

form.submit();

document.body.removeChild(form);