<object> onload not firing in Chrome

Loading a PDF in an <object> tag, I want to show an indicator while the document is being loaded instead of just an empty element, so I positioned a Load Panel over the <object>. I added a function to hide the panel:

function documentLoaded() {
    // Code to hide panel here.
}

And set it to fire in the onload event of the <object> tag:

<object type="application/pdf" data="/documents/sample.pdf" onload="documentLoaded();"></object>

This is working exactly how I want it to in Firefox and in Edge, but when I tested it in Chrome the Load Panel never went away. When I debugged it I saw that the documentLoaded() function was never called at any point.

Is there another way to get this to work with Chrome, or another way completely to call a JS function once the PDF is ready?

24 thoughts on “<object> onload not firing in Chrome”

Leave a Comment