티스토리 뷰

예전 업체쪽 어드민페이지에서 만들어쓰던 것이 있어 공유해봅니다.

불필요한 와꾸나 테이블, 스타일 관련라인 모두 제외했고 각 파일의 핵심 구문만 올렸습니다.

관리자모드에서 팝업을 관리할 수 있고, 홈페이지에서 팝업창으로 보여줄 지, 레이어형태로 보여줄 지 2가지 모두 올립니다.

가끔 이런 보잘것없는 소스라도 필요하신 분이 있으시다면 도움이 됐으면 좋겠네요.

 

 

1. 먼저 팝업 테이블을 DB에 만들어야겠죠.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE TABLE pop
(
    pop_cd                 int                not null    primary key identity(1,1)
,    pop_tit                nvarchar(150)    null
,    pop_width            int                null
,    pop_height            int                null
,    pop_left            int                null
,    pop_right            int                null
,    pop_link            nvarchar(200)    null
,    pop_txt                ntext            null
,    pop_issu_ymd        smalldatetime    null        default getdate()
,    pop_prt_yn            nvarchar(1)        null        default 'Y'
,    pop_prt_ymd            smalldatetime    null
,    pop_del_yn            nvarchar(1)        null        default 'N'
,    pop_del_ymd            smalldatetime    null
)
 
GO
cs

 


2. pop.asp - 등록한 팝업메뉴들이 보이는 리스트 페이지입니다.

1
2
3
4
5
    sql = "select pop_cd, pop_width, pop_height, pop_left, pop_right, pop_link,
 pop_txt from pop where pop_prt_yn = 'Y' and pop_del_yn = 'N' order by pop_cd desc"
    set rs = dbcon.execute(sql)
    i = 1
    do until rs.eof
cs


3. pop_write.asp - 팝업 등록 페이지입니다. (form으로 넘겨주세요~ 생략)


4. pop_write_ok.asp - 팝업 등록처리 페이지입니다.

1
2
3
4
5
6
7
8
9
10
11
12
    sql = "exec sp_pop_insert " _
        & changeword("C", ip) _
        & ", " & changeword("N", pop_cd) _
        & ", " & changeword("C", pop_tit) _
        & ", " & changeword("N", pop_width) _
        & ", " & changeword("N", pop_height) _
        & ", " & changeword("N", pop_left) _
        & ", " & changeword("N", pop_right) _
        & ", " & changeword("C", pop_link) _
        & ", " & changeword("C", pop_txt)
 
    dbcon.Execute(sql)
cs

 

 

5. pop_yn.asp 혹은 pop_proc.asp - 팝업 노출여부 처리 페이지입니다.

1
2
3
4
5
6
    sql = "exec sp_pop_proc " _
        & changeword("C", ip) _
        & ", " & changeword("N", pop_cd) _
        & ", " & changeword("N", proc_gb)
 
    dbcon.Execute(sql)
cs

 

 

6. 홈페이지 - 레이어 팝업 형태입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<script type="text/javascript">
    function setCookie1(name, value, expiredays) {
        var todayDate1 = new Date();
        todayDate1.setDate(todayDate1.getDate() + expiredays);
        document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate1.toGMTString() + ";";
    }
    /* 추가부분 */
    function setCookie2(name, value, expiredays) {
        var todayDate2 = new Date();
        todayDate2.setDate(todayDate2.getDate() + expiredays);
        document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate2.toGMTString() + ";";
    }
    function setCookie3(name, value, expiredays) {
        var todayDate3 = new Date();
        todayDate3.setDate(todayDate3.getDate() + expiredays);
        document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate3.toGMTString() + ";";
    }
    function setCookie4(name, value, expiredays) {
        var todayDate4 = new Date();
        todayDate4.setDate(todayDate4.getDate() + expiredays);
        document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate4.toGMTString() + ";";
    }
    function setCookie5(name, value, expiredays) {
        var todayDate5 = new Date();
        todayDate5.setDate(todayDate5.getDate() + expiredays);
        document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate5.toGMTString() + ";";
    }
    /* 추가부분끝 */
    function closeWin1() {
        if (document.notice_form1.chkbox1.checked) {
            setCookie1("maindiv1""done"1);
        }
        document.getElementById("divpop1").style.visibility = "hidden";
    }
    /* 추가부분 */
    function closeWin2() {
        if (document.notice_form2.chkbox2.checked) {
            setCookie2("maindiv2""done"1);
        }
        document.getElementById("divpop2").style.visibility = "hidden";
    }
    function closeWin3() {
        if (document.notice_form3.chkbox3.checked) {
            setCookie3("maindiv3""done"1);
        }
        document.getElementById("divpop3").style.visibility = "hidden";
    }
    function closeWin4() {
        if (document.notice_form4.chkbox4.checked) {
            setCookie4("maindiv4""done"1);
        }
        document.getElementById("divpop4").style.visibility = "hidden";
    }
    function closeWin5() {
        if (document.notice_form5.chkbox5.checked) {
            setCookie5("maindiv5""done"1);
        }
        document.getElementById("divpop5").style.visibility = "hidden";
    }
 
    function closePop(i) {
        document.getElementById("divpop" + i).style.visibility = "hidden";
    }
    /* 추가부분끝 */
</script>
</head>
<body>
 
 
<%
    sql = "select pop_cd, pop_width, pop_height, pop_left, pop_right, pop_link, pop_txt from pop 
where pop_prt_yn = 'Y' and pop_del_yn = 'N' order by pop_cd desc"
    set rs = dbcon.execute(sql)
    i = 1
    do until rs.eof
%>
<!-- 레이어 팝업 시작 -->
<form name="notice_form<%=i%>"> 
    <div id="divpop<%=i%>" style="width:<%=rs("pop_width")%>px; height:<%=rs("pop_height")%>px;
 position:absolute; left:<%=rs("pop_left")%>px; top:<%=rs("pop_right")%>px; z-index:100000; visibility:visible;">
        <table width="<%=rs("pop_width")%>" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td onclick="javascript:window.open('<%=rs("pop_link")%>','_blank');" <if rs("pop_link")<>"" then %>
style="cursor:pointer"<% end if %>><%=CWord2(rs("pop_txt"))%></td>
            </tr>
            <tr>
                <td height="20" bgcolor="#333" align="right"> 
                    <input type="checkbox" name="chkbox<%=i%>" value="checkbox" onclick="javascript:closeWin<%=i%>();" />
                    <font color="#FFFFFF"><span style="font-size:11px;">오늘 하루 창닫기</span></font>
                    <a href="javascript:closePop('<%=i%>');" style="color: #fff; font-weight: bold;">
<span style="font-size:11px;">[X]</span></a> &nbsp;
                </td> 
            </tr>
        </table>
    </div>
</form> 
    
<script type="text/javascript">
    var cookiedata<%=i%> = document.cookie;
    if (cookiedata<%=i%>.indexOf("maindiv<%=i%>=done"< 0) {
        document.getElementById("divpop<%=i%>").style.visibility = "visible";
    } else {
        document.getElementById("divpop<%=i%>").style.visibility = "hidden";
    }
</script>
<%
    i = i + 1
    rs.movenext : loop
    rs.close
%>
cs

 

 

7-1. 홈페이지 - 팝업창 형태입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<script type="text/JavaScript">
<!--
    function setCookie( name, value, expiredays )
    {
        var todayDate = new Date();
        todayDate.setDate( todayDate.getDate() + expiredays );
        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
    }
 
    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 )) == -)
                    endOfCookie = document.cookie.length;
                return unescape( document.cookie.substring( y, endOfCookie ) );
            }
            x = document.cookie.indexOf( " ", x ) + 1;
            if ( x == )
                break;
        }
        return "";
    }
 
 
    <%
        sql = "select pop_cd, pop_width, pop_height, pop_left, pop_right from pop where pop_prt_yn = 'Y' and pop_del_yn = 'N' order by pop_cd desc"
        set rs = dbcon.execute(sql)
        
        do until rs.eof
    %>
    if ( getCookie( "pop<%=rs("pop_cd") %>" ) != "done" )
    {
         popupWindow<%=rs("pop_cd") %>  =  window.open('popup/popup.asp?cd=<%=rs("pop_cd") %>','pop<%=rs("pop_cd") %>','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=<%=rs("pop_width") %>,height=<%=rs("pop_height")+25 %>, left=<%=rs("pop_left") %>, top=<%=rs("pop_right") %>');
         popupWindow<%=rs("pop_cd") %>.opener = self;
    }
 
    <%
            rs.movenext
        loop
        rs.close
    %>
//-->
</script>
cs


7-2.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<form>
<table width="<%=pop_width %>" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td onclick="javascript:opener.location.href='<%=pop_link%>'; window.close();" <if pop_link<>"" then %>style="cursor:pointer;"<% end if %>><%=Word_View("H", pop_txt) %></td>
  </tr>
  <tr> 
    <td valign=bottom>
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td bgcolor="#000000">
            <div align="right">
              <input type="checkbox" name="popup3" value="Y">
            </div>
          </td>
          <td width="167" height="25"><div align="right"><a href="#11" onClick="closeWin()"><img src="/popup/image/091023_close.jpg" width="167" height="25" border="0"></a></div></td>
        </tr>
      </form>
    </table>
    </td>
    </tr>
</table>
</form>
cs

 

도움이 되셨나요??

 

우와 그나저나 이거 답이 없네요;;;

js 안에 asp 혼용이랑 html안에 asp 혼용은 대체 pre class brush 속성을 어떻게 줘야 합니까??

아니면 원래 2개 섞어 쓰는건 SyntaxHighlighter에서 지원 안하나요?? ㅠㅠ

아시는 분 가르쳐주세요. ㅠㅠ

그냥 인용구 써야 겠네요.

그리고 하이라이트구문 많이 쓰니 중간에 문장 한줄씩 넣은게 크기가 제각각이네요.

따로 크기랑 지정해줘버렸네요. 에디터 왜 이러는거죠...

 

2018.1.23 소스보기 수정


즐거운 웹라이프 되세요 :)


댓글