php 保存 Iframe 内容时出错

发布于 2024-10-12 09:29:34 字数 405 浏览 4 评论 0原文

var htmll = $("#iframe1").html();
alert(htmll);
$("#myTextarea")
         .val(htmll)
         .parents("form")
         .submit();

我正在得到

警报(html1);

作为空白。 iframe在HTML中的位置是

<body>
<iframe id="iframe1" src="load.php?sinput=<?php echo $_GET['sinput'] ?>" > </iframe>
</body>
var htmll = $("#iframe1").html();
alert(htmll);
$("#myTextarea")
         .val(htmll)
         .parents("form")
         .submit();

I am getting the

alert(html1);

as blank.
The location of iframe in the HTML is

<body>
<iframe id="iframe1" src="load.php?sinput=<?php echo $_GET['sinput'] ?>" > </iframe>
</body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-10-19 09:29:34

我不知道你的 JQuery 代码,但我知道你可以执行类似

document.getElementById("iframe1").contentDocument.body.innerHTML 的

操作,但是,如果这与你执行此操作的页面不在同一域中,那么你就会得到一个安全例外。

如果你想筛选抓取的内容,你就必须比这更聪明。另外,这实际上不是一个 PHP 问题。

I dunno about your JQuery code, but I know you could do something like

document.getElementById("iframe1").contentDocument.body.innerHTML

BUT, if this isn't in the same domain as the page you're executing this from, then you're going to get a security exception.

If you're trying to screen scrape, you're going to have to be more clever than that. Also, this isn't actually a PHP question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文