익스플로러에선 정상작동이 되는데 크롬에서는 정상작동이 되지않아요. -오늘 하루 창닫기 팝업창-
본문
익스에선 오늘 하루 열지않기를 꾹 누르면 새로고침해도 다시 생기지가 않는데
크롬에선 창닫기를 누르나 오늘 하루 열지않기를 누르나 상관없이 새로고침하면 계속 열리고 있어요.
흐음 .. ㅠ,ㅠ 아고공..
최고상단에 메인메뉴 위에 스르르 올라가는 팝업창의 소스를 보여드리 자면 이렇습니다.
<script language="jscript">
jQuery(document).ready(function(){
jQuery('.scrollbar-light').scrollbar();
});
</script>
<!-- -->
<script language="jscript">
function closeWinAt01(winName) {
$("#div_laypopup").animate({height:0}, 1000);
}
</script>
<!-- //바로가기 메뉴 -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<style type="text/css">
* { margin:0; padding:0; }
#close { font:bold 12px dotum; color:#fff; cursor:pointer; }
#div1 { background:#000; width:100%; height:80px; }
#div2 { width:100%; min-width:1060px; }
#div_laypopup { background:#e4e4e4; }
</style>
<div id="div_laypopup" align="center" style="width:100%; display:none; height:100px; overflow:hidden;">
<div style="width:1060px; position:relative; bottom:-40px; left:400px;">
<input type="checkbox" name="close" id="close" value="OK" onclick="closeWinAt00('div_laypopup', 1);"/>24시간 동안 열지않기 <!--<label for="close">Today not to open the window</label>-->
</div>
<div id="div2" style="position:relative; bottom:-10px; left:500px;" onclick="closeWinAt01('div_laypopup');"><img src="<?php echo G5_URL ?>/images/common/t_pop_close.png" /></div>
</div>
<script type="text/javascript">
openWin('div_laypopup');
// 창열기
function openWin( winName ) {
var blnCookie = getCookie( winName );
var obj = eval( "window." + winName );
if( !blnCookie ) {
obj.style.display = "block";
}
}
// 창닫기
function closeWinAt00(winName, expiredays) {
setCookieAt00( winName, "done", expiredays);
var obj = eval( "window." + winName );
//obj.style.display = "none";
$("#div_laypopup").animate({height:0}, 1000);
}
// 쿠키 가져오기
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 "";
}
// 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() + ";"
}
</script>
답변 2
스크립트 선언을 하실때
<script language="jscript"> 와 같이 하지 마시고
<script language="javascript"> 로 해서 테스트해보세요.
그리고, 제이쿼리 선언 부분인
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
이 코드는 제이쿼리를 사용하기 전에 먼저 선언해 주세요. 지금은 제이쿼리 사용을 하고 있는 중간에 선언이 되어 있네요.
익스랑 다른 웹브라우저간에는 쿠키가 다르게 굽힙니다.
크롬에서 쿠키를 못굽나보네여 위소스로
getCookie로 쿠키값 확인해보세여