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 正文中有一个链接。
如何通过 click() 函数在父页面上使用 jquery 单击 iframe 中仅在页面加载后出现的链接?
如果您不在同一个域中,那么由于同源策略可能无法实现。
如果您在同一个域中,
$('#iFrameID').contents().find('#linkID').click();
应该管用。希望该代码所做的是自我解释。
如果您不在同一个域中,您可以将 HTML“欺骗”到您自己的域中。看到这里..实际上基本上这个问题。
编辑:
问题实际上是“加载 iFrame 后如何访问它?”
当 iFrame 中的页面加载时,您需要某种调用函数。有关一些示例,请参见此处。