一、iframe使用
iframe在一个页面中,相当于整个window窗口的子窗口,可通过页面的元素结构查看。
<div>
<p>学习iframe</p>
<form id='form' action="ajax1" method="post" target="ifra">
<input type="text">
<input type="button" value="提交" class="btn" onclick="ajaxSubmit5()">
</form>
<iframe id="iframe" name="ifra" style="height: 100px;width: 250px;" ></iframe>
</div>
……
function ajaxSubmit5() {
document.getElementById('iframe').onload = reloadIframe;
$('#form').submit();
}
function reloadIframe() {
//ret = this.contentWindow.document.body.innerText
ret = $(this).contents().find('body').text()
data = JSON.parse(ret)
if (data.status == 'success')
alert('welcome')
}