How does jquery call the js function of another page to solve the problem of two iframes calling each other's js function on the same page?

If the iframe of b.html is in a.html, then reference the following method

1. Call the parent class function method in the child iframe:

window.parent.func();

2. Get the elements of the parent interface in the child Iframe:

$("#xx", window.parent.document);

This xx is the ID of the element to be obtained in the parent interface.

3. jquery  calls the js method in the sub-iframe page:

iframefunction() is the method function name of the subpage

$(window.parent.document).contents().find("#iframename")[0].contentWindow.iframefunction();

Guess you like

Origin blog.csdn.net/weixin_52691965/article/details/125240584