Code Lab
일반 팝업
jaiyah
2016. 9. 29. 13:11
일반 팝업 타입 1
function popup(url, w, h, name, option) {
var pozX, pozY;
var sw = screen.availWidth;
var sh = screen.availHeight;
var scroll = 0;
if (option == 'scroll') {
scroll = 1;
}
pozX = (sw - w) / 2;
pozY = (sh - h) / 2;
window.open(url, name, "location=0,status=0,scrollbars=" + scroll + ",resizable=1,width=" + w + ",height=" + h +
",left=" + pozX + ",top=" + pozY);
}
일반 팝업 타입 2
function winPop(url, opts) {
var popupName = opts.name || 'popup';
var options = '';
options += 'width=' + (opts.width ? opts.width : 200) + ', height=' + (opts.height ? opts.height : 200);
options += opts.left && opts.width ? ', left=' + opts.left : ', left=' + ( (screen.availWidth - opts.width) / 2);
options += opts.top && opts.height ? ', top=' + opts.top : ', top=' + ( (screen.availHeight - opts.height) / 2);
options += opts.scrollbars ? ', scrollbars=' + opts.scrollbars : ', scrollbars=no';
options += opts.resizable ? ', resizable=' + opts.resizable : ', resizable=no';
console.log(popupName);
window.open(url, popupName, options);
}
Related links
Jaehee's WebClub