Is there a safe way to check the loading of frames in an HTML page?

Asked

Viewed 517 times

6

Some time ago I built a tool with HTML and Javascript to help debug a family of web applications.

Basically, the tool consists of a static HTML page and a collection of scripts that load a given system in an iframe and then make it possible to inspect several elements of that system, without the developer having to analyze the source code.

To do this, the tool needs to identify when the user accessed a certain screen to then inspect the elements.

However, the systems also used frames, sometimes in more than one level. My solution was to go through this "tree" of frames by adding listeners to identify when each frame was loaded.

My question is: is there an elegant solution using jQuery or javascript to identify the loading of a frame hierarchy?

  • 1

    Sane frames or iframes?

  • 1

    @mgibsonbr The tool has an iframe, the systems usually have a Frameset.

  • 1

    To suggest something more elegant, it would be good to ask the question the method currently in use, in order to innovate or suggest something different!

  • @Zuul I am without my notebook. I will post snippets of the code tonight.

  • And the method in use? It is already possible to ask the same question?

1 answer

3

My solution was to scroll through this "frame tree" by adding listeners to identify when each frame was loaded.

This is the only solution, there is no magic or voodoo that checks at once if an object hierarchy window or document fully charged.

I don’t know the details of your implementation, but the solution I imagine to be more elegant is to create a generic function (or maybe create a jQuery plugin) to handle it using Promises or firing an event when everything is loaded. So you isolate this problem and don’t mess up your logic.

  • Is it possible to see an example along with the answer? In its current form it is merely theoretical!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.