ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 웹페이지에서 Layout 처리 하기 위하여 표기 방법
    Spring 2017. 6. 12. 14:17




    웹페이지 호출 시 팝업 차단 / 브라우저 환경에 따라 팝업으로 표현하면 안되고 사용자에게 무조건적으로 표현되어야할 경우들이 존재하는데 이럴때 사용합니다.

     

    • 로그인 페이지 등에서 팝업 차단 및 별도 변수들을 막기 위해서 layout을 기용해야할 경우들이 존재

      <script type="text/javascript">
      // 창열기
      function openWin( winName ) {
          var blnCookie    = getCookie( winName );
          var obj = eval( "window." + winName );
          if( !blnCookie ) {
              obj.style.display = "block";
          }
      }
       
      // 창닫기
      function closeWinSetCookie(winName, expiredays) {
          setCookie( winName, "done" , expiredays);
          var obj = eval( "window." + winName );
          obj.style.display = "none";
      }
      function closeWin(winName) {
          var obj = eval( "window." + winName );
          obj.style.display = "none";
      }
       
       
      // 쿠키 가져오기
      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 "";
      }
       
       
      // 24시간 기준 쿠키 설정하기
      // expiredays 후의 클릭한 시간까지 쿠키 설정
      function setCookie( name, value, expiredays ) {
          var todayDate = new Date();
          todayDate.setDate( todayDate.getDate() + expiredays );
          document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
      }
       
      // 00:00 시 기준 쿠키 설정하기
      // expiredays 의 새벽  00:00:00 까지 쿠키 설정
      function setCookieAt00( name, value, expiredays ) {
          var todayDate = new Date();
          todayDate = new Date(parseInt(todayDate.getTime() / 86400000) * 86400000 + 54000000);
          if ( todayDate > new Date() )
          {
              expiredays = expiredays - 1;
          }
          todayDate.setDate( todayDate.getDate() + expiredays );
          document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
      }
      function helpOpen() {
          window.open(app.contextPath + "/help/ko/help.html"'ImportUser',
              'width=1200,height=800,scrollbars=yes,status=yes');
      }
      </script>
        
      <body>
      <div id="layout" style="z-index: 10000; position: absolute; width: 400px; left: 140px; top: 130px; display: none;">
         <form name="form1" style="padding:0pt;margin:0pt">
            <table width="100%" height="100%" cellspacing="0" border="0" bgcolor="#f2f2f2">
               <tbody><tr>
                  <td valign="top" style="padding:0px;">
                     <a href="#" onclick="helpOpen()"><img src="${staticURL}/sens-static/images/common/open_help.png" border="0"></a>                  </td>
               </tr>
               <tr>
                  <td height="25" bgcolor="#919191" align="right" width="100%" style="padding-right:10px;">
                     <input type="checkbox" name="close" value="OK" onclick="closeWinSetCookie('layout', 1)"/>하루동안 이 창을 열지 않음
       
                     <a href="#" onclick="closeWin('layout')" class="font4">[닫기]</a>
                  </td>
               </tr>
               </tbody></table>
         </form>
      </div>
      </body>
        

     

    댓글

Designed by black7375.