Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed a div only to display once every session
    primarykey
    data
    text
    <p>I am trying to figure out how to make a certain div to show up once each time a person goes on my website. I have seen two ways of doing this using javascript and php but no success.</p> <p>Here is my code, I would like (if possible) the #spinner div (and everything in it) to be displayed once every session.</p> <pre><code>&lt;body&gt; ****This part would only be displayed once**** &lt;div id="spinner" style="display: none;"&gt; &lt;div class="sketch"&gt; &lt;canvas id="canvas" width="1280" height="224"&gt;&lt;/canvas&gt; &lt;script&gt;var canvas = document.getElementById('canvas') , context = canvas.getContext('2d') , img = new Image() , w , h , offset , glitchInterval; img.src = 'http://www.bccustommade.com/images/loading.png'; img.onload = function() { init(); window.onresize = init; }; var init = function() { clearInterval(glitchInterval); canvas.width = w = window.innerWidth; offset = w * .1; canvas.height = h = ~~(175 * ((w - (offset * 2)) / img.width)); glitchInterval = setInterval(function() { clear(); context.drawImage(img, 0, 110, img.width, 175, offset, 0, w - (offset * 2), h); setTimeout(glitchImg, randInt(250, 1000)); }, 500); }; var clear = function() { context.rect(0, 0, w, h); context.fill(); }; var glitchImg = function() { for (var i = 0; i &lt; randInt(1, 13); i++) { var x = Math.random() * w; var y = Math.random() * h; var spliceWidth = w - x; var spliceHeight = randInt(5, h / 3); context.drawImage(canvas, 0, y, spliceWidth, spliceHeight, x, y, spliceWidth, spliceHeight); context.drawImage(canvas, spliceWidth, y, x, spliceHeight, 0, y, x, spliceHeight); } }; var randInt = function(a, b) { return ~~(Math.random() * (b - a) + a); };&lt;/script&gt; &lt;/div&gt; &lt;div class="loading"&gt; &lt;div class="loading-dot"&gt;&lt;/div&gt; &lt;div class="loading-dot"&gt;&lt;/div&gt; &lt;div class="loading-dot"&gt;&lt;/div&gt; &lt;div class="loading-dot"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ****This part would only be displayed once**** </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload