How do I display a “loading..” while <iframe id="pdfViewer" name="pdfViewer" src="foo.pdf"></iframe> are not ready? I’m not web developer. My first try was do it by using JavaScript, but:
var xhr = new XMLHttpRequest;
xhr.Open("GET", "foo.pdf");
xhr.onreadystatechange = function()
{
if(this.readyState == 4) {
document.getElementById("container").innerHTML = this.responseText;
}
}
xhr.send(null);
I can’t use jQuery solutions here because I can’t use it.
Trivial example: jsfiddle.net/G5wkS/
Create a placeholder and an iframe (initially hidden). Of course you could choose to write these out in HTML too, and place them wherever you want with your own styling and attributes. Then, once the iframe’s
onloadfires, take away the placeholder and unhide the iframe. You might want to do something different if theonerrorevent fires instead.