每个用户/浏览器会话仅显示一次欢迎div [英] Show welcome div only once per user / browser session
本文介绍了每个用户/浏览器会话仅显示一次欢迎div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想每个用户或会话仅显示一次欢迎div。我知道有Jquery选项。既然我是jquery的新手,我一直无法自己解决它。请帮助
#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>你好!..<峰; br>欢迎来到ABC< br> < / H1> < h2>我们祝你有美好的一天!!< / h2> <峰; br> < h2>< a id =close-welcomehref =#>谢谢您,请带我到网站< / a> < / H2> < / div>< / div>
我想只显示一次这个欢迎页面,直到用户关闭浏览器。
等待有价值的帮助
解决方案
设置cookie 。
$ b $
$(document).ready(function(){
if($ .cookie('noShowWelcome')) )$('。welcome')。hide();
else {
$(#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屋!
查看全文