JS Call parent frame function and Play window simple method of calling parent page function _javascript Tips

Source: Internet
Author: User
Tags sub domain

Call the AAA function in the parent

Sub-page:

Onclick= "Window.parent.frames.aaa ()"

In the parent page:

function aaa ()
{
alert (' bbbbb ');
}

The pages in frame frames should be changed to other pages in the frame or the parent frame with parent

Window.opener refers to the parent page of the window.open open page.

The Window.frames object can refer to the page in the IFRAME, or to the page in the frameset.

Can do this

Window.frames[0].document.getelementbyid (' xx ');

Can do this

window.frames[0].document.body.innerhtml;

frm = window.parent.window.frames[' uploadframe '];
Frmdocument = frm.document;
FRM.SB (3); SB is a function in the Uploadframe page

For Firefox

If you encounter an error: Parent.document.frames has no properties

Replace it with the following code, this code is IE,FF compatible. frm = window.parent.window.frames[' uploadframe '; in fact, the frames collection is not hanging in the document but hanging under the Window object.

Note that there is a limit to the page in the frame, which must be under the same domain, otherwise inaccessible

If it is under the same domain, but the sub domain name is different, then the js,html file involved adds a sentence.

Document.domain = xxx.com [fill in your domain name here]

document.getElementById (' Iframeid '). ContentWindow.document.getElementById (' Someelementid ');

Call parent page function after JS window page

(For example: Invoke parent page Function test2 ())
Window.opener.test2 ();

Frame subpage calls the previous page method

(For example: the frame frame named menubar on the previous page, call the Onhook () function)
window.top.frames["MenuBar"].onhook ();

JS window page Call parent page Frame Child page function

(such as: Play Window page call, frame named menubar)
window.opener.top.frames[' MenuBar '].onhook ();

The above is small series for everyone to bring JS call the parent frame function and the window to call the parent page function of the simple method of all the content, I hope that we support cloud-Habitat Community ~

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.