Hello, Can anyone help me with a JS function or anything else to reload automatically a flash swf object on my website every x min ? Thanks
<!doctype html> <html> <head> <title>Test</title> </head> <body> <img id="swfobject" src="image.jpg" /> <script type="text/javascript"> function reloadSwf(element) { console.log(element) var el = document.getElementById(element); var elSrc = el.getAttribute("src"); var rand = ''; setInterval(function() { for(var i = 0; i <= 15; i++) { rand += Math.floor( Math.random() * 10 ) + 1; } el.setAttribute("src", elSrc + "?" + rand); }, 5000); } var id = "swfobject"; if(document.addEventListener) { document.addEventListener("DOMContentLoaded", function() { document.removeEventListener("DOMContentLoaded", arguments.callee, false); reloadSwf(id); }, false); } else { document.attachEvent("onreadystatechange", function() { if(document.readyState === "complete") { document.detachEvent("onreadystatechange", arguments.callee); reloadSwf(id); } }); } </script> </body> </html> Code (markup): Tested @ Webkit (Chrome). The idea is pretty simple - from time to time append a random string to the object's original source and reload the element. This will force the browser to completely reload the swf as it will be triggered to think that its a different object. I've used an image as an example, but you can use it on any element that has a src attribute. Good luck!