简体   繁体   English

如何从iframe内部获取字段数据?

[英]how to grab a fields data from inside an iframe?

I am trying to pull data from inside an iframe that links to http://www.w3schools.com/ . 我试图从链接到http://www.w3schools.com/的iframe内部提取数据。 I keep getting errors that won't allow me to pull out the data of any field or grab the entire page's html and put it into a variable. 我不断收到错误消息,不允许我提取任何字段的数据或获取整个页面的html并将其放入变量中。

I have already tried: 我已经尝试过:

$('iframe').html();

I have also tried not loading it in an iframe so it could be accessed easier, but that also didn't work. 我也尝试过不将其加载到iframe中,这样可以更轻松地访问它,但这也行不通。

 $(function(){
          $("#includedContent").load("http://www.w3schools.com"); 
        });

要从iframe主体获取内容,您应该使用:

$("iframe").contents().find('body').html();

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

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