I have a list of files. When i click on them, the contents are displayed inside an frame. The problem i have is: when i open one file and move to next one (if the file is of greater size, it takes some time to load), the contents of old file still shows up in iframe. As soon as i click next file, i want to clear the contents of old file in iframe and meanwhile it's loading i can display a loading indicator.
To clear the contents inside iframe i tried some ways but could not succeed. Can you advise me on this
My HTML
<div id="result">
<div style="overflow: auto;" id="testIframeBox">
<iframe id="testiframe" name="testIframe" onload="">iFramenot supported</iframe></div>
</div>
I show up the clicked file using location.replace
window.frames['testIframe'].location.replace(URL+"&download=1&inline=1&resourceId="+resourceId+"&time=" + Date.now());
To clear contents:
if(document.getElementById('testiframe'))
{
var frame = document.getElementById("testIframe"),
frameDoc = frame.contentDocument || frame.contentWindow.document;
frameDoc.documentElement.innerHTML="";
}
Also i tried to replace the contents with loading indicator before filling the contents:
window.frames['testIframe'].location.replace('div class="loading-animation"></div>');