如果您使用了很多框架,如何找到文档的最父主体元素。在一个 iframe 里面也有几个 iframe,我想为最上层的文档主体调用一个函数。
下面的工作,除了你每次都必须为 parent 计数。
$(parent.parent.parent.parent.document.body).function('loading');
没有这样的东西吗?
$(parentOfAllParents.document.body).function('loading');
最佳答案
这对任何 iframe
都是有用的:top.window.document.body
关于javascript - 使用javascript查找最上层父窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13839828/