[easyui] Manipulate the components of the parent window in the iframe

Encountered a problem in the project:

  It is necessary to operate the tabs component of the parent window in the iframe to add a new window, and the operation will always report an error:

jquery.easyui.min.js:4995 Uncaught TypeError: Cannot read property 'tabs' of undefined
    at _37d (jquery.easyui.min.js:4995)
    at _37c (jquery.easyui.min.js:5077)
    at Object.exists (jquery.easyui.min.js:5149)
    at m.fn.init.$.fn.tabs (jquery.easyui.min.js:5095)
    at add (xxx.html:17)
    at HTMLAnchorElement.onclick (childFrame.html:30)

Solution taken from: https://www.cnblogs.com/puke/archive/2012/09/13/2683067.html

It is hereby recorded.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Usually in the iframe child page, to get the elements of the parent window, the operation is generally as follows:

js:  window.parent.document.getElementById('id');  

jq:   $('selector', window.parent.document);

However, in easyui, the component that operates the parent element can indeed get the element through the above method, but an error will be reported as soon as the method is called;

The solution is as follows:

  parent.$('selector').tabs('exists', 'title');

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324919586&siteId=291194637