JavaScript Windows XP에서 팝업 정상작동
페이지 정보
본문
준비물 : 팝업이미지.jpg , test.html
IE 6.01 및 FF 1.6 에서 모두 정상 작동됩니다.
Windows XP 팝업차단 옵션에 영향을 받지 않습니다.
하루동안 창 안뜨기 기능을 결합하면 금상첨화일텐데... 성공하시는분 있으시면 연락을 ^^
test.html 문서 내용
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
// 팝업 닫기
function closePOPUP() {
document.getElementById("happyjung_popup").style.display = "none";
}
//-->
</script>
</head>
<body>
<!-- 팝업 -->
<div id="happyjung_popup" style="position: absolute; margin: 150 0 0 160;">
<table b0rder="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="팝업이미지.jpg" onClick="closePOPUP()" style="cursor:hand" title="닫기"></td>
</tr>
</table>
</div>
</body>
</html>
test.html 에서 happyjung_popup 는 팝업 고유값 이며, 이용시 변경해 사용을하세요.
드림아이 ( www.dreami.com )에서 사용하는 방법
////////////////////////////////////////////////////////////////////
<준비1> index.php 본문에 아래 코드 삽입
////////////////////////////////////////////////////////////////////
<script language="javascript" src="http://www.dreami.com/js/popup.js"></script>
<script language="javascript" src="http://www.dreami.com/js/cookieLib.js"></script>
<script language="javascript">
strReturn = GetCookie('http://www.dreami.com/popup/popup200610');
if(strReturn == '' || strReturn == null || strReturn == '0') {
p_windowopen("popup20061219", "/2006_1219/popup.html", 341, 526, 110, 320); //창이름, url, 가로사이즈, 세로사이즈, 창위치(상단기준), 창위치(좌측기준)
}
</script>
////////////////////////////////////////////////////////////////////
<준비2> popup.html 문서준비
////////////////////////////////////////////////////////////////////
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>공지사항!</title>
<SCRIPT language="JavaScript">
<!--
var pID = "popup20061219";
function windowclose(bCookie, strURL) {
parent.p_windowclose(pID, bCookie, strURL);
}
function move(bCookie) { // 본문내용중 특정 링크 클릭후 부모창의 어떤 페이지를 열어라는 선언
parent.location.href='/package_regist/seminar.php?menu6=6'; // 열릴 페이지 주소
windowclose(bCookie, '');
}
//-->
</SCRIPT>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<table>
<tr>
<td colspan="2">누르면 <a href="javascript:move('0');"> 부모창에서 상세내용 열기</a></td>
</tr>
<tr>
<td><a href="javascript:windowclose('2','');">다음부터 이창열지 않기</a></td>
<td><a href="href="javascript:windowclose('0','');">닫기</a></td>
</tr>
</table>
</body>
</html>
////////////////////////////////////////////////////////////////////
<준비3> popup.js 문서준비
////////////////////////////////////////////////////////////////////
<SCRIPT language="JavaScript">
<!--
var arrPopup = new Array;
var nPopup = 0;
function p_windowclose(pID, bSetCookie, strURL, dm) {
var iDiv;
if (bSetCookie == "1"){ //더이상열지않기
SetCookie_Layer_PA_michoi(pID, "1", dm);
} else if(bSetCookie == "2"){ //하루동안열지않기
SetCookie_Layer_PA_michoi(pID, "2", dm);
}
else if(bSetCookie == "3"){ //영원히열지않기
SetCookie_Layer_PA_michoi(pID, "3", dm);
}
for( i=0 ; i < nPopup; i++){
if(pID == arrPopup[i]){
iDiv = arrPopup[i];
break;
}
}
document.all[iDiv].style.display="none";
if (strURL != "") document.location.href = strURL;
}
function p_windowopen(pID, pPopSrc, pWidth, pHeight, Top, Left){
var pTop, pLeft;
pTop = posPopup.offsetTop + Top;
pLeft = popLeft.offsetLeft + Left;
arrPopup[nPopup] = pID;
if ( nPopup != 0 ){
pTop = posPopup.offsetTop + (nPopup * 40);
pLeft = popLeft.offsetLeft + (nPopup * 200);
}
nPopup = nPopup + 1;
strPopupScript = "<div id='" + pID + "' onclick='javascript:alert(\"d\")' style='border-width:0px;POSITION: absolute;TOP: " + pTop + "px; LEFT: " + pLeft + "px;z-index:199'>\
<IFRAME src='" + pPopSrc + "' frameBorder=0 scrolling=no width=" + pWidth + " height=" + pHeight + "></IFRAME>\
</div>";
document.writeln(strPopupScript);
}
function p_windowupper(pID){
var iDiv;
var nZindex;
for( i=0 ; i < nPopup; i++){
iDiv = arrPopup[i];
if (pID == iDiv) nZindex = 300;
else nZindex = 200;
document.all[iDiv].style.zIndex = nZindex;
}
}
function p_moveLayer(){
var iDiv;
for( i=0 ; i < nPopup; i++){
iDiv = arrPopup[i];
document.all[iDiv].style.left = popLeft.offsetLeft + (i * 200) + 20;
}
}
window.onresize = p_moveLayer;
//-->
</script>
////////////////////////////////////////////////////////////////////
<준비3> cookieLib.js 문서준비
////////////////////////////////////////////////////////////////////
<SCRIPT language="JavaScript">
<!--
function GetCookie( name ){
var nameOfCookie = name + "=";
var x = 0;
while ( x <= document.cookie.length )
{
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
endOfCookie = document.cookie.length;
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 ) break;
}
return "";
}
function SetCookie(sName, sValue, dm)
{
var expDays = 1; // 쿠키 만료기간(일수)
var todayDate = new Date();
if(!dm)
var cookieDomain = ".dreami.com";
else
var cookieDomain = dm;
var cookiePath = "/";
if (sValue == "3") expDays = 3650;
todayDate.setDate(todayDate.getDate() + expDays);
if (sValue == "1") {
document.cookie = sName + "=" + escape(sValue);
} else if (sValue == "2" || sValue == "3") {
document.cookie = sName + "=" + escape(sValue) + ";" +
"expires=" + todayDate.toGMTString() + ";" +
"path=" + cookiePath + ";" +
"domain=" + cookieDomain;
}
}
function SetCookie_Layer_PA_michoi(sName, sValue, dm)
{
var expDays = 1; // 쿠키 만료기간(일수)
var todayDate = new Date();
if(!dm)
var cookieDomain = ".dreami.com";
else
var cookieDomain = dm;
var cookiePath = "/";
if (sValue == "3") expDays = 3650;
todayDate.setDate(todayDate.getDate() + expDays);
if (sValue == "1") {
document.cookie = sName + "=" + escape(sValue);
} else if (sValue == "2" || sValue == "3") {
document.cookie = sName + "=" + escape(sValue) + ";" +
"expires=" + todayDate.toGMTString() + ";" +
"path=" + cookiePath + ";" +
"domain=" + cookieDomain;
}
}
//-->
</script>
IE 6.01 및 FF 1.6 에서 모두 정상 작동됩니다.
Windows XP 팝업차단 옵션에 영향을 받지 않습니다.
하루동안 창 안뜨기 기능을 결합하면 금상첨화일텐데... 성공하시는분 있으시면 연락을 ^^
test.html 문서 내용
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
// 팝업 닫기
function closePOPUP() {
document.getElementById("happyjung_popup").style.display = "none";
}
//-->
</script>
</head>
<body>
<!-- 팝업 -->
<div id="happyjung_popup" style="position: absolute; margin: 150 0 0 160;">
<table b0rder="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="팝업이미지.jpg" onClick="closePOPUP()" style="cursor:hand" title="닫기"></td>
</tr>
</table>
</div>
</body>
</html>
test.html 에서 happyjung_popup 는 팝업 고유값 이며, 이용시 변경해 사용을하세요.
드림아이 ( www.dreami.com )에서 사용하는 방법
////////////////////////////////////////////////////////////////////
<준비1> index.php 본문에 아래 코드 삽입
////////////////////////////////////////////////////////////////////
<script language="javascript" src="http://www.dreami.com/js/popup.js"></script>
<script language="javascript" src="http://www.dreami.com/js/cookieLib.js"></script>
<script language="javascript">
strReturn = GetCookie('http://www.dreami.com/popup/popup200610');
if(strReturn == '' || strReturn == null || strReturn == '0') {
p_windowopen("popup20061219", "/2006_1219/popup.html", 341, 526, 110, 320); //창이름, url, 가로사이즈, 세로사이즈, 창위치(상단기준), 창위치(좌측기준)
}
</script>
////////////////////////////////////////////////////////////////////
<준비2> popup.html 문서준비
////////////////////////////////////////////////////////////////////
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>공지사항!</title>
<SCRIPT language="JavaScript">
<!--
var pID = "popup20061219";
function windowclose(bCookie, strURL) {
parent.p_windowclose(pID, bCookie, strURL);
}
function move(bCookie) { // 본문내용중 특정 링크 클릭후 부모창의 어떤 페이지를 열어라는 선언
parent.location.href='/package_regist/seminar.php?menu6=6'; // 열릴 페이지 주소
windowclose(bCookie, '');
}
//-->
</SCRIPT>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<table>
<tr>
<td colspan="2">누르면 <a href="javascript:move('0');"> 부모창에서 상세내용 열기</a></td>
</tr>
<tr>
<td><a href="javascript:windowclose('2','');">다음부터 이창열지 않기</a></td>
<td><a href="href="javascript:windowclose('0','');">닫기</a></td>
</tr>
</table>
</body>
</html>
////////////////////////////////////////////////////////////////////
<준비3> popup.js 문서준비
////////////////////////////////////////////////////////////////////
<SCRIPT language="JavaScript">
<!--
var arrPopup = new Array;
var nPopup = 0;
function p_windowclose(pID, bSetCookie, strURL, dm) {
var iDiv;
if (bSetCookie == "1"){ //더이상열지않기
SetCookie_Layer_PA_michoi(pID, "1", dm);
} else if(bSetCookie == "2"){ //하루동안열지않기
SetCookie_Layer_PA_michoi(pID, "2", dm);
}
else if(bSetCookie == "3"){ //영원히열지않기
SetCookie_Layer_PA_michoi(pID, "3", dm);
}
for( i=0 ; i < nPopup; i++){
if(pID == arrPopup[i]){
iDiv = arrPopup[i];
break;
}
}
document.all[iDiv].style.display="none";
if (strURL != "") document.location.href = strURL;
}
function p_windowopen(pID, pPopSrc, pWidth, pHeight, Top, Left){
var pTop, pLeft;
pTop = posPopup.offsetTop + Top;
pLeft = popLeft.offsetLeft + Left;
arrPopup[nPopup] = pID;
if ( nPopup != 0 ){
pTop = posPopup.offsetTop + (nPopup * 40);
pLeft = popLeft.offsetLeft + (nPopup * 200);
}
nPopup = nPopup + 1;
strPopupScript = "<div id='" + pID + "' onclick='javascript:alert(\"d\")' style='border-width:0px;POSITION: absolute;TOP: " + pTop + "px; LEFT: " + pLeft + "px;z-index:199'>\
<IFRAME src='" + pPopSrc + "' frameBorder=0 scrolling=no width=" + pWidth + " height=" + pHeight + "></IFRAME>\
</div>";
document.writeln(strPopupScript);
}
function p_windowupper(pID){
var iDiv;
var nZindex;
for( i=0 ; i < nPopup; i++){
iDiv = arrPopup[i];
if (pID == iDiv) nZindex = 300;
else nZindex = 200;
document.all[iDiv].style.zIndex = nZindex;
}
}
function p_moveLayer(){
var iDiv;
for( i=0 ; i < nPopup; i++){
iDiv = arrPopup[i];
document.all[iDiv].style.left = popLeft.offsetLeft + (i * 200) + 20;
}
}
window.onresize = p_moveLayer;
//-->
</script>
////////////////////////////////////////////////////////////////////
<준비3> cookieLib.js 문서준비
////////////////////////////////////////////////////////////////////
<SCRIPT language="JavaScript">
<!--
function GetCookie( name ){
var nameOfCookie = name + "=";
var x = 0;
while ( x <= document.cookie.length )
{
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
endOfCookie = document.cookie.length;
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 ) break;
}
return "";
}
function SetCookie(sName, sValue, dm)
{
var expDays = 1; // 쿠키 만료기간(일수)
var todayDate = new Date();
if(!dm)
var cookieDomain = ".dreami.com";
else
var cookieDomain = dm;
var cookiePath = "/";
if (sValue == "3") expDays = 3650;
todayDate.setDate(todayDate.getDate() + expDays);
if (sValue == "1") {
document.cookie = sName + "=" + escape(sValue);
} else if (sValue == "2" || sValue == "3") {
document.cookie = sName + "=" + escape(sValue) + ";" +
"expires=" + todayDate.toGMTString() + ";" +
"path=" + cookiePath + ";" +
"domain=" + cookieDomain;
}
}
function SetCookie_Layer_PA_michoi(sName, sValue, dm)
{
var expDays = 1; // 쿠키 만료기간(일수)
var todayDate = new Date();
if(!dm)
var cookieDomain = ".dreami.com";
else
var cookieDomain = dm;
var cookiePath = "/";
if (sValue == "3") expDays = 3650;
todayDate.setDate(todayDate.getDate() + expDays);
if (sValue == "1") {
document.cookie = sName + "=" + escape(sValue);
} else if (sValue == "2" || sValue == "3") {
document.cookie = sName + "=" + escape(sValue) + ";" +
"expires=" + todayDate.toGMTString() + ";" +
"path=" + cookiePath + ";" +
"domain=" + cookieDomain;
}
}
//-->
</script>
댓글목록
등록된 댓글이 없습니다.