이호영 이호영 2025-02-20
안심번호 팝업 중앙정렬 및 기존 크기 오류 해결
@fc29e38eb671235d429398e23faea90ee8f2163e
src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataSMLView.jsp
--- src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataSMLView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataSMLView.jsp
@@ -3195,21 +3195,53 @@
 //fnLetterListAjax();
 
 /* 윈도우팝업 열기 */
-function infoPop(pageUrl){
+/* 윈도우팝업 열기 */
+var infoPopT; // 전역 변수로 선언하여 팝업 추적
+
+function infoPop(pageUrl) {
+	// 기존 팝업이 존재하면 닫기
+	if (infoPopT && !infoPopT.closed) {
+		infoPopT.close();
+	}
+
+	// 기본값 설정
+	let width = 790, height = 350;
+
+	if (pageUrl === "adrvertisement1") {
+		width = 790;
+		height = 800;
+	} else if (pageUrl === "selectMsgDataView3") {
+		width = 500;
+		height = 550;
+	}
+
+	// 🔥 현재 브라우저 창 크기 가져오기
+	let screenWidth = window.innerWidth || document.documentElement.clientWidth || screen.width;
+	let screenHeight = window.innerHeight || document.documentElement.clientHeight || screen.height;
+
+	// 💡 팝업을 브라우저 창 중앙에 위치시키기 위해 `top`, `left` 계산
+	let left = (screenWidth - width) / 2 + window.screenX;
+	let top = (screenHeight - height) / 2 + window.screenY;
+
+	// 📝 옵션 문자열 (정확한 중앙 정렬 적용)
+	let options = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left +
+		",fullscreen=no,menubar=no,status=no,toolbar=no,titlebar=yes,location=no,scrollbars=1";
+
+	console.log('팝업 옵션 : ', options);
+
+	// 🔥 window.open() 호출
+	infoPopT = window.open("", 'infoPop', options);
+
+	// 🔄 폼 데이터 설정 및 제출
 	document.popForm.pageType.value = pageUrl;
 	document.popForm.action = "/web/pop/infoPop.do";
-	document.popForm.method = "post"; 
-	if(pageUrl == "adrvertisement1"){
-		window.open("about:blank", 'infoPop', 'width=790, height=800, top=100, left=100, fullscreen=no, menubar=no, status=no, toolbar=no, titlebar=yes, location=no, scrollbars=1');	
-	}else if(pageUrl == "selectMsgDataView3"){
-		window.open("about:blank", 'infoPop', 'width=500, height=550, top=100, left=100, fullscreen=no, menubar=no, status=no, toolbar=no, titlebar=yes, location=no, scrollbars=1');	
-	}else{
-		window.open("about:blank", 'infoPop', 'width=790, height=350, top=100, left=100, fullscreen=no, menubar=no, status=no, toolbar=no, titlebar=yes, location=no, scrollbars=1');	
-	}
-	
+	document.popForm.method = "post";
 	document.popForm.target = "infoPop";
 	document.popForm.submit();
 }
+
+
+
 
 
 $(document).on('click', '.addressregi_btn', function() {
@@ -3984,7 +4016,7 @@
 					</c:when>
 					<c:otherwise>
 						대량문자(광고문자)
-			<button type="button" class="button info ad_btn" onclick="infoPop('adrvertisement1');" style="right: 128px;"><i></i>광고규정</button>
+						<button type="button" class="button info ad_btn" onclick="infoPop('adrvertisement1');" style="right: 128px;"><i></i>광고규정</button>
 					</c:otherwise>
 				</c:choose>
 			</h2>
Add a comment
List