一、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')
}
创建iframe和Form表单

相关文章:

  • 2022-01-17
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-12-03
猜你喜欢
  • 2021-06-27
  • 2022-02-04
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
相关资源
相似解决方案