简体   繁体   English

Javascript:获取ID的正文

[英]Javascript: Get body of an ID

I am trying to get body content of iframe using either Javascript or jQuery. 我正在尝试使用Javascript或jQuery获取iframe正文内容。 I have tried to solve the problem several ways, but none of them worked for me. 我试图通过几种方法解决该问题,但是没有一个对我有用。

The solutions I tried looked like these: 我尝试的解决方案如下所示:

document.getElementById('iframe').document.innerHTML;

$("#content").contents().find("body").html();
document.getElementById("iframe").contentWindow.document.body.innerHTML

如果iframe来自同一域,则可以在作为iframe src url的URL上执行$.ajax请求?

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

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