2012-10-18 5 views
0

안녕하세요, 쿠키가 페이지로드에 표시되면 쿠키를 만들려고합니다.하지만 쿠키가 생성되지 않는다고 생각하기 때문에 여전히 팝업이 표시됩니다. 아무도 왜 이런 일이 일어나고 내 실수는 어디서 할 수 있습니까?jquery popup always shows

그래서 여기 내 popup.js 파일 내용

//SETTING UP OUR POPUP 
//0 means disabled; 1 means enabled; 
var popupStatus = 0; 

//loading popup with jQuery magic! 
function loadPopup(){ 
    //loads popup only if it is disabled 
    if(popupStatus==0){ 
     $("#backgroundPopup").css({ 
      "opacity": "0.7" 
     }); 
     $("#backgroundPopup").fadeIn("slow"); 
     $("#popupContact").fadeIn("slow"); 
     popupStatus = 1; 
    } 
} 

//disabling popup with jQuery magic! 
function disablePopup(){ 
    //disables popup only if it is enabled 
    if(popupStatus==1){ 
     $("#backgroundPopup").fadeOut("slow"); 
     $("#popupContact").fadeOut("slow"); 
     popupStatus = 0; 
    } 
} 

//centering popup 
function centerPopup(){ 
    //request data for centering 
    var windowWidth = document.documentElement.clientWidth; 
    var windowHeight = document.documentElement.clientHeight; 
    var popupHeight = $("#popupContact").height(); 
    var popupWidth = $("#popupContact").width(); 
    //centering 
    $("#popupContact").css({ 
     "position": "absolute", 
     "top": windowHeight/2-popupHeight/2, 
     "left": windowWidth/2-popupWidth/2 
    }); 
    //only need force for IE6 

    $("#backgroundPopup").css({ 
     "height": windowHeight 
    }); 

} 
//---------------cookies-------------------// 

function getCookie(c_name) 
{ 
var i,x,y,ARRcookies=document.cookie.split(";"); 
for (i=0;i<ARRcookies.length;i++) 
    { 
    x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); 
    y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); 
    x=x.replace(/^\s+|\s+$/g,""); 
    if (x==c_name) 
    { 
    return unescape(y); 
    } 
    } 
} 

function setCookie(c_name,value,exdays) 
{ 
var exdate=new Date(); 
exdate.setDate(exdate.getDate() + exdays); 
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); 
alert(c_value); 
document.cookie=c_name + "=" + c_value; 
} 

function checkCookie() 
{ 
var username=getCookie("shoppingKatalog"); 
if (username!=null && username!="") 
    { 
    alert(username); 
    } 
else 
    { 
    //centering with css 
    centerPopup(); 
    //load popup 
    loadPopup();  
    setCookie("shoppingKatalog","istekuva-za-eden-den",321); 
    } 
} 

//--------------end cookies---------------// 


//CONTROLLING EVENTS IN jQuery 
$(document).ready(function(){ 

    checkCookie(); 
    //LOADING POPUP 
    //Click the button event! 
    $("#button").click(function(){ 
     //centering with css 
     centerPopup(); 
     //load popup 
     loadPopup(); 
    }); 

    //CLOSING POPUP 
    //Click the x event! 
    $("#popupContactClose").click(function(){ 
     disablePopup(); 
    }); 
    //Click out event! 
    $("#backgroundPopup").click(function(){ 
     disablePopup(); 
    }); 
    //Press Escape event! 
    $(document).keypress(function(e){ 
     if(e.keyCode==27 && popupStatus==1){ 
      disablePopup(); 
     } 
    }); 

}); 

내 index.html 파일

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>yensdesign.com - How to create a stuning and smooth popup in jQuery</title> 
    <link rel="stylesheet" href="http://www.mywebsite.com/templates/it_theshop/popup/general.css" type="text/css" media="screen" /> 
    <script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script> 
    <script src="http://www.mywebsite.com/templates/it_theshop/popup/popup.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
    </script> 
</head> 
<body> 

    <center> 
     <a href="http://www.yensdesign.com"><img src="logo.jpg" alt="Go to yensdesign.com"/></a> 
    </center> 
    <div id="popupContact"> 
     <div id="popup_wrap" style="background-image:url('http://www.mywebsite.com/templates/it_theshop/images/popup/shopping-popup1.jpg');height:380px;width:800px;"> 
<div style="float:left;width:490px;padding:5px;"> 
<h1 style="margin:0px;">Заштеди до <span style="color:#981A32;">90%</span></h1> 
<h2 style="margin:0px;">Имајте ја информацијата - <span style="color:#981A32;">ПРВИ!</span></h2> 
<p style="margin:0px;">Дознај каде може да добиеш огромен попуст на чевли, облека, накит, козметика, производи за дома, услуги, патувања... Се она што го плаќаш во секојдневниот живот.</p> 
<h4 style="margin:0px;">Нашиот Newsletter е БЕСПЛАТЕН!</h4> 
<form method="post"> 

<table class="acymailing_form"> 
<p style="color:#981A32;margin:0px;">Одберете ја типот на информација што сакате да ја добивате:</p> 
<tr> 
<td align="left"><input type="checkbox" class="acymailing_checkbox" name="subscription[]" checked="checked" value="1" /><b style="color:#981A32;">СИТЕ ПОПУСТИ И ПРОИЗВОДИ</b></td> 
</tr> 
<tr> 
<td align="left"><input type="checkbox" class="acymailing_checkbox" name="subscription[]" value="2" /> 
<b style="color:#981A32;">САМО НОВИ ПРОИЗВОДИ</b></td> 
</tr> 
<tr> 
<td align="left"><input type="checkbox" class="acymailing_checkbox" name="subscription[]" value="4" /><b style="color:#981A32;">САМО ПОПУСТИ</b></td> 
</tr> 
<tr style="color:#981A32;"> 
<td><label for="user_name">Име</label><input id="user_name" type="text" name="user[name]" value="" /></td> 
</tr> 
<tr> 
<td style="color:#981A32;"><label for="user_email">E-мејл</label><input id="user_email" type="text" name="user[email]" value="" /></td> 
</tr> 
<tr> 
<td><div style="display:none;"><label for="user_html">Добивај</label></div></td> 
<td><div style="display:none;"><input type="radio" name="user[html]" value="0" id="user_html_0" /><label for="user_html_0">Text</label></div><div style="display:none;"><input type="radio" name="user[html]" value="1" id="user_html_1" checked="checked" /><label for="user_html_1">HTML</label></div></td> 
</tr> 

<tr> 
<td colspan="2"> 
<div style="display:none;"> 
<input type="radio" name="task" value="optin" checked="checked" id="optin" /><label for="optin">Subscribe</label> 
<input type="radio" name="task" value="optout" id="opftout" /><label for="optout">Unsubscribe</label> </div> 
<input class="button" type="submit" value="Пријави се БЕСПЛАТНО!" name="Submit" style="color: white;background-color: orange;border: 0;border-radius: 5px;height: 30px;font-weight: bold;margin-top:5px;" onclick="setCookie('mywebsite','istekuva-za-godina',364);" /></td> 
</tr> 
</table> 
<input type="hidden" name="gtask" value="sub" style="color:#981A32;" /> 
<input type="hidden" name="redirect" value="http://www.mywebsite.com" /> 
<input type="hidden" name="option" value="com_acymailing" /> 
<input type="hidden" name="visiblelists" value="1,2,4" /> 
<input type="hidden" name="hiddenlists" value="YOUR_LISTS" /> 
</form> 
</div> 
<img src="http://www.mywebsite.com/templates/it_theshop/images/popup/popust.png" style="float:right;padding-right:-10px;position: absolute;margin-left: 260px;" /> 
</div> 
    </div> 
    <div id="backgroundPopup"></div> 
</body> 
</html> 
+0

'http : // www.mywebsite.com/templates/it_theshop/popup/popup.js'에는 이것에 대해보고 된 버그가 없습니다. 100 % 고체입니까? –

+0

@ BerkerYüceer 그것은 내 자신의 파일이다. – Darko

+0

나는 내가 왜 당신에게 ur js 파일이 올바르게 작동하는지 묻고있는 thats를 볼 수있다. –

답변

0

쿠키가 생성되었습니다. 함수 checkCookie()에서 사용하고 있기 때문에

if (username!=null && username!="") 
{ 
alert(username); 
} 

여기서 조건은 null이 아닙니다. 그래서 쿠키가 생성되었습니다

0

가 기본적으로 숨겨져 있지 않기 때문에 팝업이 표시되어 있습니다. CSS에 의해 숨겨 지도록 노력하십시오 :

#backgroundPopup { display:none } 

이는 처음에는 숨기고 필요한 경우 표시해야합니다.

+0

그것의 숨김, 매개 변수는 내가 포함하지 않은 CSS 파일에있다. – Darko

+0

어느 브라우저를 사용하고 있습니까? –

+0

크롬 및 파이어 폭 – Darko