Rerun script every time presentation loads

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I have a presentation with a number of text and an image field in it.  I added a script to the head of the presentation in HTML which loads random data from a json page and modifies the text and image fields based on that data.  When the presentation first gets run, the data loads nicely and changes all of the fields.  The problem I have is that the data then gets cached and doesn't run the script the second and third and all subsequent times though the presentation.  Is there a way to force it to rerun that script so that it gets different random data the next time?
Photo of Steven


  • 150 Points 100 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb

Let me ask around a bit and get back to you on this question. It's a new one!
Photo of Donna Peplinskie

Donna Peplinskie

  • 7,142 Points 5k badge 2x thumb

You'll likely need to append some random dummy query parameter at the end of the URL that requests the JSON so that it isn't served from the browser cache.

Photo of Steven


  • 150 Points 100 badge 2x thumb
I just tried that.  It appears the script itself is not getting run (on the second time through the schedule), it's not that the JSON data is not getting updated.  Is there something that the player calls when loading a presentation every time through a schedule like window.onload() (but not that one, I tried it, same issues)?

I'm assuming this is because the player is caching the whole page so that the player can run offline.

Photo of Joseph Mayberry

Joseph Mayberry

  • 1,206 Points 1k badge 2x thumb
you can use a setInterval() call somewhere in the HTML. I won't have it run every time that the presentation comes up again, but you can have it refresh the data at set internals dictated by the variables you feed into the command

setInterval(function(){ yourFunction(); }, 60000); would call your script every minute.

This will also still let the page run from the cache in the event that a connection is lost.

But make sure that you make that call from outside of the function that you want to have repeat (otherwise you will create an infinite, self replicating, loop that will over tax your connection.