我需要将iframe转换为字符串变量,然后使用php发送到服务器:
<center><iframe id="probando" src="prueba2.html" scrolling="auto" height="700" width="800" marginheight="0" marginwidth="0" name="probando"></iframe></center>
我不知道如何继续......
请帮帮我。致谢!!!
答案 0 :(得分:4)
这个答案是使用jQuery获取iframe中的内容。请注意,这将在您自己的域中按预期工作:
$(function(){
$('#probando').on('load', function(){
var str = $(this).contents().find('html').prop('outerHTML');
console.log(str);
});
});
答案 1 :(得分:2)
var html = document.getElementById("probando").outerHTML;
答案 2 :(得分:1)
使用
var string = $('center').html();
或者您可以使用
var string = $('#probando').closest('center').html();