REF (ref에는 일반 javascript방식도 포함되어 있어요)

REF - window센터맞추기(dual포함)



팝업 뛰우기:


var witdh = 600;

var height = 400;

var left = (screen.width/2)-(witdh/2);

var top = (screen.height/2)-(height/2);

window.open('url','myTitle',

'top=' + top +',left='+ left +',width=' + width + ',height=' + height +  ',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');


크롬에서 size조절이 잘 안될 경우에는 아래 css 추가

<style>

html,body {overflow: hidden;}

</style>



그리고, 듀얼 스크린을 고려한 w/h는 

var w = 600;

var h = 550;

//dual

var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;

    var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;


    var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;

    var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;


    var left = ((width / 2) - (w / 2)) + dualScreenLeft;

    var top = ((height / 2) - (h / 2)) + dualScreenTop;





팝업에서 부모창에 값 전달하기

$("#parentId", opener.document).val(부모창으로 전달할 값);



부모창에서 값 가져오기

$("#parentId", opener.document).val();


사용빈도는 낮지만, 부모창에 존재하는 함수호출

$(opener.location).attr("href", "javascript:부모스크립트 함수명();");



부모창 Submit:

var form =  $('#searchForm', opener.document);

form.submit();



//팝업창 닫기

window.self.close();


//부모창 refresh

window.opener.document.location.reload();


Posted by yongary
,