Login / Join
Javascript Disposable Alert
submitted on 21/09/2016 by
Codicode
+ infos
Config
Embed
Share
Javascript Disposable Alert
by
Codicode
Javascript disposable alert showing only once and tracked by cookies
Framework 1 :
-- None --
jQuery 2.0.3
jQuery 1.9.1
jQuery 1.9.0
jQuery 1.8.0
jQuery 1.7.1
jQuery 1.6.3
jQuery UI 1.10.3
MooTools 1.4.5
AngularJS 1.0.4
Prototype 1.7.1.0
Dojo 1.8.3
Chrome Frame 1.0.3
Ext Core 3.1.0
SWFObject 2.2
WebFont Loader 1.1.2
Framework 2 :
-- None --
jQuery 2.0.3
jQuery 1.9.1
jQuery 1.9.0
jQuery 1.8.0
jQuery 1.7.1
jQuery 1.6.3
jQuery UI 1.10.3
MooTools 1.4.5
AngularJS 1.0.4
Prototype 1.7.1.0
Dojo 1.8.3
Chrome Frame 1.0.3
Ext Core 3.1.0
SWFObject 2.2
WebFont Loader 1.1.2
+ Js file(s) :
+ Css file(s) :
Apply
Link :
Direct http link :
Fork button :
Html code :
Embed preview :
Copy the following html code to your page to embed the preview,
To include many previews on a single page, just repeat the first line.
You can change the width, height and border color (bcolor).
<div class="refork-widget" code="d30" style="width:100%;height:200px;" bcolor="#ccc"></div>
<script type="text/javascript" src="//snippet.run/d/z.js"></script>
HTML
CSS
.CookiesAlert { background-color: #123; color:#fff; padding : 10px 30px; text-align:center; position : fixed; bottom:10px; right:10px; max-width:600px; border-radius : 3px; } .CookiesAlert span { display: inline-block; color:#000; background-color:white; padding:3px 6px; border-radius : 3px; margin-left:10px; cursor:pointer; }
Javascript
function createCookie(name, value, days) { var expires; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } else { expires = ""; } document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/"; } function readCookie(name) { var nameEQ = encodeURIComponent(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 decodeURIComponent(c.substring(nameEQ.length, c.length)); } return null; } function eraseCookie(name) { createCookie(name, "", -1); } function setupCookiesAlert(){ if (readCookie("CookiesAlert")!=="clicked"){ var alertText = "Ce site utilise des cookies pour assurer une meilleure navigation sur le site "; var aldiv = $('<div class="CookiesAlert">' + alertText + '</div>'); var albnt = $('<span>Ok</span>').click(function(){ eraseCookie("CookiesAlert"); createCookie("CookiesAlert","clicked",60); aldiv.remove(); }); aldiv.append(albnt); $("body").append(aldiv); } } setupCookiesAlert();
©2013 Copyright snippet.run
Privacy
-
Terms of use
-
About
-
Contact