Frames, scripts and boot order

If I have a document with a set of frames and some javascript defined in the main tag, then there is something like this:

<html> <head> <script> function foo() {} </script> </head> <frameset> <frame src="A.html"> </frameset> </html> 

I already assume that the frame (A.html) fires the onLoad event handler before its parent. I am pretty sure this is a safe guess. However, is it safe to assume that the A.html script context can safely access the entire script code defined in the head of the parent window?

What assumptions can I make?

+4
source share
2 answers

According to this page , you can safely access the script in the parent , which is an object that refers to the document of the parent frame frame.

From a small local test, the onload parent event does not seem to fire , but its script tag seems to have been processed before loading the child frames.

Frames frowned these days, so be sure this is the right approach.

+1
source

The script frame will be able to access its parent JS space using the parent link. (But only if both documents are on the same host, they are in your truncated example).

I would not rely on the parent onLoad launch after A.html, although, as Phil said, the script will process first - this is because the inline script evaluation is a blocking operation.

+1
source

All Articles