简体   繁体   English

jQuery无法获取的内容 <iframe> 元件

[英]Jquery cannot get contents of <iframe> element

Hi I am trying to select form tag using Jquery from the link below in chrome console: 嗨,我正在尝试使用chrome控制台中以下链接中的Jquery选择表单标签:

http://www.dcoi-conference.org/#!registration/cpq5

I tried: 我试过了:

$("form")

This gives empty array Here I see the form element is in iframe . 这给出了空数组在这里,我看到form元素在iframe中 Thus I also tried 因此我也尝试了

$("iframe")[0].contents();

But was uanable to get any results. 但是有资格取得任何结果。 Please help. 请帮忙。

The form in that page is in an iframe that comes from a different origin than the page. 该页面中的表单位于一个iframe中,该iframe来自与该页面不同的来源。 So, the browser security model will not allow you to access the iframe DOM from the parent page. 因此,浏览器安全模型将不允许您从父页面访问iframe DOM。

Without moving the content out of that foreign domain or placing code into that foreign sourced iframe, there is no way to work around that security limitation from just the parent page. 如果不将内容移出该外部域或将代码放入该外部源iframe,就无法从父页面解决该安全限制。

Possible solutions: 可能的解决方案:

  1. Stop embedding an iframe from a foreign domain because there is no way to get to the content of a cross origin iframe. 停止从外部域嵌入iframe,因为无法获取跨源iframe的内容。 Put the content into your own page directly where you can access it freely. 将内容直接放在您自己的页面中,您可以在其中自由访问它。
  2. Add code to the foreign domain that will cooperate with the parent page. 将代码添加到将与父页面配合使用的外部域。 Cooperating cross origin frames can communicate via window.postMessage() , but it requires cooperating code in both frames in both domains. 跨源协作框架可以通过window.postMessage()进行通信,但是它需要两个域中两个框架中的协作代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM