js关闭当前页面 刷新另一页面

JavaScript015

js关闭当前页面 刷新另一页面,第1张

你可以用js监测弹出页面的关闭事件,然后刷新父页面就行了

window.onbeforeunload = function() {

    //这里刷新方法有很多,具体要看你的子窗口是怎样出来的

    window.opener.location.reload()

    //parent.location.reload()

    //self.opener.location.reload()

    //window.opener.location.href=window.opener.location.href

}

1、单纯的关闭

window.opener.location.reload() //刷新父窗口中的网页

window.close()//关闭当前窗窗口

2、提交后关闭

function save(){ 

    document.getElementById("pointsform").submit()

    alert('保存成功')

    window.opener.document.getElementById("cmd").value="query"

    window.opener.document.getElementById("form的id").submit()//提交

    window.close() //关闭当前窗口

}