Iframe onload event when content is set from srcdoc

Viewed 728

How can i specify an onload property for an iframe loaded from srcdoc attribute. For example:

<iframe id="Content" runat="server" srcdoc="Large HTML contents that are set from the server"></iframe>

I'm using asp.net webforms to populate the content from another server.

However, the normal way to trigger onload for an iframe would be the following, but that won't work:


$(function () {

    var iframe = document.getElementById(DocumentViewer.GetFrameClientID());

    console.log({iframe}) // OK

    iframe.onload = function () { // Never Trigger unless i add a src attribute instead of srcdoc
        console.log('loaded')
    }
})

I found an issue reported on github in 2018 "load" event handler is called prematurely for iframe.srcdoc

Any clue?

0 Answers
Related