The parent page calls JS in the child page
Let's create a subform first
Copy code code as follows:
VAR win
$ (function () {
Root = $ (' #root '). Val ()//Set the root directory
});
function Openplayer (ID, type, add) {
This is used to restrict the same window that only pops up once
In fact, even without the restriction, as long as the name in the window.open parameter is the same, it will not open repeatedly
the parameters in//window.open can refer to other articles, there are many
if (win = null | | win.closed) {
Win = window.open (' http://loaclhost/sl.asp tutorial x ', ' win ', ' width=870,height=650,top=1,left=0,scrollbars=0,resizable=0 , Status=1 ', true);
}
So how do you call it?
Copy code code as follows:
This.alert (' Hello world! ');
Win.alert (' Hello world! ');
Win.onload = function () {This.alert (' test ');
As we all know, the first line is to pop a prompt box in this window (this
can be generally omitted ~)
Well, actually, this and win point to the same type, different objects.
So, their methods are the same.
The second line is the code that pops a prompt box in a child window.
You can also write the child form event in the parent form ~
The third line is that when the subform is loaded, the parent window pops up the prompt box.
Second, the subform calls the parent form
This is similar to the above, when the parent form opens a subform, you can access the parent form like this