How to refresh parent page after closing popup window in javascript?

前端 未结 2 656
孤独总比滥情好
孤独总比滥情好 2021-02-06 18:19

I have one page list.jsp having list of all records in table and one button at top to add new record.

I want to open add.jsp as a popup window.

2条回答
  •  醉话见心
    2021-02-06 18:28

    You could use location.reload(true) to reload the current document. The forceGet parameter is by default false and that is why you pass it in as true to overwrite it. Basically it is used to fetch the document from the server, instead of loading it from the cache.

    EDIT1: If you are trying to reload the source window of the popup, as escaparello mentioned in the comments, you should call window.opener.location.reload(). Also, you could bind an event listener for when the popup unloads, as follows:

    popupWindow.onunload = function () {
        // This informs the user that the record has been added successfully
        alert('The record has been inserted into the database!');
    
        window.opener.location.reload();
    }
    

提交回复
热议问题