1

i need to display an iframe with an automatic refresh intervall of 10 seconds. For this i use these code - it works:

But now i want to integrate that the iframe only refresh when there is no user activity on the page (scrolling, clicking). Is it possible to restart the timer when an user activity is detected?

<html>
<head>
<meta http-equiv="refresh" content="600">
</head>
<body>
<h2>Title</h2>
<iframe
  src="https://plugins.xxxx.com/embed/iframe/111111111111111111111"
  id="socialmedia"
  height="800" 
  style="display: block; border: none; width: 100%;"
  allowfullscreen>
</iframe>
<script>
window.setInterval("reloadIFrame();", 10000);

function reloadIFrame() {
 var frameHolder=document.getElementById('socialmedia');
frameHolder.src="https://plugins.xxxx.com/embed/iframe/111111111111111111111"
}
</script>
</body>
</html>
nils50122
  • 63
  • 5
  • Does this answer your question? [How to detect idle time in JavaScript](https://stackoverflow.com/questions/667555/how-to-detect-idle-time-in-javascript) – Nico Haase Jan 17 '22 at 14:07

0 Answers0