每个用户/浏览器会话仅显示一次欢迎 div [英] Show welcome div only once per user / browser session
本文介绍了每个用户/浏览器会话仅显示一次欢迎 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想为每个用户或会话显示一次欢迎 div.我知道有 Jquery 选项.由于我是 jquery 的新手,我一直无法自己解决.请帮忙
$(document).ready(function() {$("#close-welcome").click(function() {$(".welcome").fadeOut(1000);});});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div class="欢迎"><div><h1>你好..!<br>欢迎来到ABC<br><h2>祝您有个美好的一天..!</h2><br><h2><a id="close-welcome" href="#">谢谢..请带我去网站</a>
我只想显示此欢迎页面一次,直到用户关闭浏览器..等待宝贵的帮助
解决方案
设置 cookie.
$(document).ready(function() {if ($.cookie('noShowWelcome')) $('.welcome').hide();别的 {$("#close-welcome").click(function() {$(".welcome").fadeOut(1000);$.cookie('noShowWelcome', true);});}});
您需要包含 jQuery.cookie javascript 文件.
https://raw.githubusercontent.com/carhartl/jquery-cookie/master/src/jquery.cookie.js
I want to show a welcome div only once per user or session. I know that there is Jquery option. Since am a newbie to jquery, I have not been able to resolve it myself. Please help
$(document).ready(function() {
$("#close-welcome").click(function() {
$(".welcome").fadeOut(1000);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="welcome">
<div>
<h1>Hello..!<br> Welcome to ABC
<br>
</h1>
<h2>We wish you a Great Day..!</h2>
<br>
<h2><a id="close-welcome" href="#">Thank you.. and please take me to the website</a> </h2>
</div>
</div>
I want to show this welcome page only once, till the user closes the browser.. Awaiting valuable help
解决方案
Set a cookie.
$(document).ready(function() {
if ($.cookie('noShowWelcome')) $('.welcome').hide();
else {
$("#close-welcome").click(function() {
$(".welcome").fadeOut(1000);
$.cookie('noShowWelcome', true);
});
}
});
You need to include jQuery.cookie javascript file.
https://raw.githubusercontent.com/carhartl/jquery-cookie/master/src/jquery.cookie.js
这篇关于每个用户/浏览器会话仅显示一次欢迎 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文