Javascript 延迟后显示cookie警报
我发现了一个使用基于引导的cookie警报的好例子。我正在尝试修改代码,并将其用作要求用户对页面/网站进行排名的表单Javascript 延迟后显示cookie警报,javascript,html,twitter-bootstrap,cookies,Javascript,Html,Twitter Bootstrap,Cookies,我发现了一个使用基于引导的cookie警报的好例子。我正在尝试修改代码,并将其用作要求用户对页面/网站进行排名的表单 <div id="cookie-alert" data-expire="30" class="alert alert-primary alert-position-bottom"> <div class="container"> <button type="button" class="close" data-dismiss
<div id="cookie-alert" data-expire="30" class="alert alert-primary alert-position-bottom">
<div class="container">
<button type="button" class="close" data-dismiss="alert">
<span class="cookie-close-btn" aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<p class="fs-13">
<i class="fa fa-warning"></i>
We use cookies to provide you with a better service.
Carry on browsing if you're happy with this, or find out how to
<a href="#">manage cookies</a>.
</p>
</div>
</div>
×
接近
我们使用cookies为您提供更好的服务。
如果您对此感到满意,请继续浏览,或者了解如何
.
有没有办法在延迟5-10分钟后或在特定页面多次访问后显示
我在这里找到了代码:
这只是一个简单的例子。将以下内容添加到文件中 CSS: JS:
把时间改成你喜欢的时间。请记住,这只是一个简单的例子。这只是一个简单的例子。将以下内容添加到文件中 CSS: JS:
把时间改成你喜欢的时间。请记住,这只是一个简单的示例。要显示带有延迟的消息,您可以使用如下简单内容:
// Vanilla JS to show it after period of time
var cookieDiv = document.getElementById('cookie-alert');
cookieDiv.style.display = 'none';
setTimeout(function(){
cookieDiv.style.display='block';
},5000) // Show it after 5000ms
示例如下:
要延迟显示该消息,您可以使用以下简单方法:
// Vanilla JS to show it after period of time
var cookieDiv = document.getElementById('cookie-alert');
cookieDiv.style.display = 'none';
setTimeout(function(){
cookieDiv.style.display='block';
},5000) // Show it after 5000ms
示例如下:
// Vanilla JS to show it after period of time
var cookieDiv = document.getElementById('cookie-alert');
cookieDiv.style.display = 'none';
setTimeout(function(){
cookieDiv.style.display='block';
},5000) // Show it after 5000ms