The parent and child windows call each other JS code (1/3)

Source: Internet
Author: User

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

Home 1 2 3 last

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.