在每个页面加载时显示随机DIV(对于fancybox模式) [英] Show Random DIV on every page load (For fancybox modal)
问题描述
当访问者离开网站时,我正在显示一个fancybox模式窗口。它工作正常。但作为一个分裂测试,我想在随后的访问中向访问者展示来自2个不同div的随机内容。
含义:
$ 1)当访问者1来到并试图离开网站时,他可能会看到内容为1或2的fancybox 2)当访问者2来了,并试图离开网站,他可能会再次看到fancybox与内容1或2等等...
fancybox模式的实际代码是:
< div id =inlineclass =various2风格= 显示:无; >
< div style =padding:20px;>
这是fancybox模式内显示的内容。
< / div>
< / div>
现在对于内部div,我想将另一个div加入一些不同的内容,其中一个应随机显示在每一页的加载,而另一个是显示:无......
我试过这个:如何显示每页刷新多个页面的一个div?
但是, t工作,并显示两个divs可见...
任何人都可以帮忙吗?
编辑:原来的问题被回答。现在,我怎样才能显示每个页面加载备用div。不是随机的。像访问者1,2,3,4分别看到div 1,2,3,4。
我知道这需要一些服务器任何人都可以帮助一些基本的PHP代码?
解决方案 / p>
HTML
< div id - =fancy_box>
< div id =inlineclass =various1style =display:none;>
< div style =padding:20px;>
这是fancybox模态1中显示的内容。
< / div>
< / div>
< div id =inlineclass =various2style =display:none;>
< div style =padding:20px;>
这是fancybox模态2中显示的内容。
< / div>
< / div>
< / div>
JQuery
哦,小提琴在这里
I am showing a fancybox modal window when a visitor leaves the site. It is working correctly. But as a split test, I want to show visitors random content from 2 different divs on subsequent visits.
Meaning:
1) When visitor 1 comes and tries to leave site, he might see fancybox with content 1 or 2
2) When visitor 2 comes and tries to leave site, he might again see fancybox with content 1 or 2
And so on...
The actual code for the fancybox modal is:
<div id="inline" class="various2" style="display:none;">
<div style="padding:20px;">
This is the content of that shows inside the fancybox modal.
</div>
</div>
Now for the inner div, i want to put another div with some different content, and one of them should randomly show on every page load, while the other is display:none...
I have tried this: How to show one div of many, per page refresh? But it doesn't work and shows both divs visible...
Can anyone help?
EDIT: The original question is answered. Now, how can I show alternate div on every page load. Not random. Something like visitors 1,2,3,4 see divs 1,2,3,4 respectively.
I know this would require some server side code, can anyone help with some basic php code?
I prefer timestamp over random for some reason
HTML
<div id-="fancy_box">
<div id="inline" class="various1" style="display:none;">
<div style="padding:20px;">
This is the content of that shows inside the fancybox modal 1.
</div>
</div>
<div id="inline" class="various2" style="display:none;">
<div style="padding:20px;">
This is the content of that shows inside the fancybox modal 2.
</div>
</div>
</div>
JQuery
$(function(){
$(".various"+(new Date().getTime() % 2 +1)).css("display", "block");
});
Oh and the fiddle is here
这篇关于在每个页面加载时显示随机DIV(对于fancybox模式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!