Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在通过 iframe 加载页面。如果内容位于 iframe 内,我需要添加加载微调器,如果没有,则不需要微调器。
问题:我如何使用 jQuery 从iframe中的内容中检查它当前是否位于 iframe 中?
(即,将 jQuery 添加到加载 iframe 本身的页面很简单,但我需要 jQuery 代码位于 iframe内加载的文件中)。
怎么样
if ( self !== top ) { // you're in an iframe }