使用JavaScript查找最上层的父窗口 [英] Find most upper parent window with javascript

查看:128
本文介绍了使用JavaScript查找最上层的父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您使用很多框架,如何找到文档的最父正文元素.在也包含几个iframe的iframe内,我想为最高文档主体调用一个函数.

How to find the most parent body element of a document, if you're using a lot of frames. Inside a iframe that also is in a few iframes, I want to call a function for the most upper document body.

以下工作原理,不同之处在于您每次必须为父母数.

The following works, except that you have to count for the parents each time.

$(parent.parent.parent.parent.document.body).function('loading');

没有这样的东西吗?;

Isn't there something like this?;

$(parentOfAllParents.document.body).function('loading');

推荐答案

使用window.top.

规范在此处.

这篇关于使用JavaScript查找最上层的父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆