1
00:00:00,890 --> 00:00:06,110
As I mentioned at the end of the last video, we can allow communication between a parent frame and

2
00:00:06,110 --> 00:00:10,310
a child frame, depending upon some settings that we apply to the iFrame element.

3
00:00:10,910 --> 00:00:13,430
So let me show you another quick diagram again.

4
00:00:13,430 --> 00:00:17,600
Right now, we have some JavaScript running in the parent frame and some running inside the child frame.

5
00:00:18,200 --> 00:00:23,930
The current settings of our iFrame allow communication between these two different context.

6
00:00:24,340 --> 00:00:29,480
So just because the current settings we have, we can very easily and directly communicate between these

7
00:00:29,480 --> 00:00:30,170
two context.

8
00:00:30,690 --> 00:00:36,530
But if we change these settings, this communication link can be completely broken and we can isolate

9
00:00:36,530 --> 00:00:38,060
the iFrame from the parent.

10
00:00:38,880 --> 00:00:43,520
So let's first take a look at how everything works with our current settings, which are going to allow

11
00:00:43,520 --> 00:00:44,300
communication.

12
00:00:45,700 --> 00:00:49,150
All right, so back inside my console, I have once again selected top.

13
00:00:50,010 --> 00:00:53,820
I'm then going to declare window A equals one once again.

14
00:00:54,930 --> 00:01:02,250
Well, then change into test HTML now, just as a quick reminder, if I do window A, I get undefined

15
00:01:02,580 --> 00:01:06,540
because this iFrame element has a different JavaScript execution context.

16
00:01:06,540 --> 00:01:12,210
So I don't when I reference window, I'm referencing window inside of the iFrame rather than the index

17
00:01:12,210 --> 00:01:13,080
html file.

18
00:01:13,800 --> 00:01:19,080
But if I wanted to reference the parent, if I wanted to write some javascript inside of the child and

19
00:01:19,080 --> 00:01:23,040
somehow get access to the parent, I can write out parent.

20
00:01:25,010 --> 00:01:31,310
We write out parent inside of the inner iFrame, we can get a reference to the parent window element

21
00:01:31,310 --> 00:01:32,660
to the parent window object.

22
00:01:33,180 --> 00:01:35,780
So if I write out parent dot a.

23
00:01:37,240 --> 00:01:43,990
Now, I see that value of one again right now, because of our current settings, our child iFrame can

24
00:01:43,990 --> 00:01:46,870
try to access different things inside the parent.

25
00:01:47,500 --> 00:01:49,140
The opposite is true as well.

26
00:01:49,870 --> 00:01:55,420
So inside of my test context, I'm going to do window B equals to.

27
00:01:56,940 --> 00:01:59,160
I'll then go back into my parent context.

28
00:02:00,170 --> 00:02:08,000
Some top again, if I do window B over here, I get undefined because Window B is a sign inside the

29
00:02:08,000 --> 00:02:09,190
child, not the parent.

30
00:02:09,770 --> 00:02:15,440
But if I wanted to somehow reach from the parent into the child, I can write out the following code.

31
00:02:15,830 --> 00:02:17,510
I can do a document.

32
00:02:19,110 --> 00:02:20,020
Where is Selecter?

33
00:02:21,850 --> 00:02:22,720
Or Efraim.

34
00:02:25,600 --> 00:02:31,270
iFrame, not just frame, that's better, so it's going to give me a reference to that iFrame than to

35
00:02:31,270 --> 00:02:36,130
reach into the iFrame I can reference content window like so.

36
00:02:37,200 --> 00:02:42,450
That is going to reach from the parent into the child and get access to that window object, then if

37
00:02:42,450 --> 00:02:46,560
I try to print out the property on it, there's the number two.

38
00:02:47,280 --> 00:02:52,170
So that is an example of reaching from the parent into the child and trying to access some different

39
00:02:52,170 --> 00:02:52,770
properties.

40
00:02:54,170 --> 00:02:59,420
OK, so at this point time, clearly we are able to kind of reach across this context and kind of make

41
00:02:59,420 --> 00:03:02,480
changes or get access to properties between the two.

42
00:03:03,650 --> 00:03:07,490
But this is only because our current settings allow this level of communication.

43
00:03:08,150 --> 00:03:10,400
So let's take another brief pause, come back to the next video.

44
00:03:10,400 --> 00:03:14,540
We're going to take a look at some of the different settings we can change to break this communication

45
00:03:14,720 --> 00:03:17,480
and disallow any communication between the two.

