gpt4 book ai didi

javascript - 导航到另一个页面时,Mootools 弹出窗口不会保持关闭状态

转载 作者:行者123 更新时间:2023-11-28 08:28:50 26 4
gpt4 key购买 nike

我一直在努力处理这个弹出窗口,我希望它只向新访问者(30 天 cookie)显示一次,目前它几乎可以工作 - 每次您更改页面时它都会出现,但我希望它保留无论用户浏览哪个页面,都会在 cookie 持续时间内关闭。

您可以在此处查看示例 - www.marktoe.co.za 和下面的代码

HTML:

<div id = "theLink"><?php if($this->countModules('tekenin2')) : ?>
<div id="gototop">
<div id="popup"><a href="#" onclick="parentNode.remove();return false; ">
<img src="/templates/marktoe/images/close.png" id="close" class="close" border="0" alt="close" /></a>
<jdoc:include type="modules" name="tekenin2" style="xhtml" />
</div>
</div>
<?php endif; ?></div>


div#theLink {
width: 500px;
position: fixed;
z-index: 99999999;
top: 15%;
left: 35%;
display: none;
visibility: hidden;
}
div#popup {
border: 2px solid #8CC34A;
padding: 20px;
background-color: #FFF;
width: 500px;
opacity: 0.95;
margin: 0;
-moz-box-shadow: 10px 10px 10px 10px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 10px 10px 10px 10px rgba(0, 0, 0, 0.5);
box-shadow: 10px 10px 10px 10px rgba(0, 0, 0, 0.5);
border-top-right-radius: 15px;
border-top-left-radius: 15px;
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
}
#popup img.close {
float: right;
position: relative;
z-index: 9999;
top: 0px;
right: 0px;
}
.moduletable-nlpopup {
margin: 0;
padding: 70px 0 0 0;
background-repeat: no-repeat;
background-position: top leftpx;
border: none;
}
.moduletable-nlpopup h3 {
}
a.toplink {
font-size:10px;
}
#gototop {
font-size:10px;
width:500px;
font-size:11px;
text-decoration:none;
padding:0px;
height: 300px;
}
#gototop:hover {

}

Cookie:

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name) {
createCookie(name,"",-1);
}

function setTheDivStyle() {// body on load event
if(!readCookie('wroteIt')) {

// if cookie not found display the div and create the cookie
document.getElementById("theLink").style.display="none";
createCookie('wroteIt', 'wroteIt', 1); // 1 day = 24 hours persistence
}
else {
// if cookie found hide the div
document.getElementById("theLink").style.display="block";
}
}

任何建议将不胜感激,正如我所说,我已经为此苦苦挣扎了一段时间,但 cookie 不是我的强项。谢谢!

最佳答案

我发现我的问题与我正在使用的滚动 spy 插件有关,该插件每次加载新页面时都会重新启动弹出窗口 - 此后已删除滚动 spy ,现在的行为就像梦想一样。

关于javascript - 导航到另一个页面时,Mootools 弹出窗口不会保持关闭状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22088028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com