Javascript jquery弹出窗口始终显示
嗨,我正在尝试在页面加载上显示弹出窗口后创建cookie,但不知怎么的,弹出窗口仍然显示出来,因为我认为cookie不会创建。有谁能告诉我为什么会这样,我的错误在哪里 下面是我的popup.js文件内容Javascript jquery弹出窗口始终显示,javascript,jquery,cookies,popup,Javascript,Jquery,Cookies,Popup,嗨,我正在尝试在页面加载上显示弹出窗口后创建cookie,但不知怎么的,弹出窗口仍然显示出来,因为我认为cookie不会创建。有谁能告诉我为什么会这样,我的错误在哪里 下面是我的popup.js文件内容 //SETTING UP OUR POPUP //0 means disabled; 1 means enabled; var popupStatus = 0; //loading popup with jQuery magic! function loadPopup(){ //loa
//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();
}
});
});
//设置弹出窗口
//0表示残疾;1表示启用;
var popupStatus=0;
//用jquerymagic加载弹出窗口!
函数loadPopup(){
//仅在禁用时加载弹出窗口
if(popupStatus==0){
$(“#backgroundPopup”).css({
“不透明度”:“0.7”
});
$(“#背景弹出”).fadeIn(“慢”);
$(“#popupContact”).fadeIn(“慢”);
爆米花=1;
}
}
//使用jQuery魔术禁用弹出窗口!
函数disablePopup(){
//仅在启用时禁用弹出窗口
if(popupStatus==1){
$(“#背景弹出”).fadeOut(“慢”);
$(“popupContact”).fadeOut(“慢速”);
popupStatus=0;
}
}
//定心弹出窗口
函数centerPopup(){
//请求定心数据
var windowWidth=document.documentElement.clientWidth;
var windowHeight=document.documentElement.clientHeight;
var popupLight=$(“#popupContact”).height();
var popupWidth=$(“#popupContact”).width();
//定心
$(“#popupContact”).css({
“位置”:“绝对”,
“顶部”:窗高/2-PopLight/2,
“左”:窗宽/2-popupWidth/2
});
//IE6只需要武力
$(“#backgroundPopup”).css({
“高度”:窗高
});
}
//---------------饼干-------------------//
函数getCookie(c_名称)
{
变量i,x,y,ARRcookies=document.cookie.split(“;”);
对于(i=0;i
Заштеди до 90%
Имајте ја информацијата - ПРВИ!
(p
ааааааааааааааа107!
СИТЕ ПОПУСТИ И ПРОИЗВОДИ
САМО НОВИ ПРОИЗВОДИ
САМО ПОПУСТИ
Име
E-Мјј
Добивај
文本HTML
订阅
退订
弹出窗口显示,因为默认情况下它不隐藏。请尝试通过css将其隐藏:
#backgroundPopup { display:none }
这应该在开始时隐藏它,然后在需要时显示它。您的cookie已创建。因为在您的函数checkCookie()中,您正在使用
if (username!=null && username!="")
{
alert(username);
}
这里的条件不等于null。因此创建cookie您确定
http://www.mywebsite.com/templates/it_theshop/popup/popup.js
没有关于这方面的错误报告吗?它是100%可靠吗?@BerkerYüceer这是我自己的文件我可以看到这就是为什么我问你你确定你的js文件工作正常吗..它是隐藏的,参数在cs中s文件,我没有包含您的代码,没有警报工作:第一次加载时显示弹出窗口,之后不显示,并创建cookie。
if (username!=null && username!="")
{
alert(username);
}