Asp.net
在 iframe 中送出後如何刷新 iframe 父頁面?
我在一個頁面中有 iframe,這個 iframe 包含一個送出按鈕,它將執行一些功能。
我想要的是:iframe送出完成後,呼叫父頁面刷新。
我知道如何刷新它:
parent.location.reload();但我不知道送出完成後該怎麼做。
在我的所有方法完成後,我通過在後面的程式碼中添加這行程式碼解決了這個問題:
ScriptManager.RegisterStartupScript(this, typeof(string), "script", "<script type=text/javascript> parent.location.href = parent.location.href;</script>", false);我沒有寫
parent.location.reload()和寫的原因parent.location.href = parent.location.href是不要將數據兩次發送到伺服器,因為我想要一個新的頁面載入。
在 iframe 上使用
onload事件處理程序。當它在送出後觸發時,執行你的top.location.reload…// In parent window.onload = function() { document.getElementById("MY_IFRAME").onload = function() { top.location.reload(); } }