How to check If frame has loaded content

Continuing the discussion from IFrame Custom Component: Embed other websites in your app:

This component works well and I am using it to view PDF/Word docs by setting the url to the url of a document:

url = f"https://drive.google.com/viewerng/viewer?url={URL_FROM_HTTP}&nodl=1&embedded=true"

self.i_frame_1.url=url

where URL_FROM_HTTP is a url returned from an end point. The problem is that 50% the Google Docs viewer that I am embedding doesn’t load (apparently a well known issue with gviewer).

This works some of the time so I know the code supporting the iframe works - it is just gviewer which is having the heart murmur.

Reloading the form sometimes works so I am looking for a way to programmatically reload the iframe if the document hasnt loaded … I just don’t know how to check if the content has loaded without seeing it and clicking refresh.

I will build a minimal example over the next couple of days and post but any pointers would be appreciated.