Can I get setTimeOut() executed after page redirection?
<p>Why not Duplicate: Question wasn't answered in previous post.</p>

<p>I have a delete link, which when get clicked triggers a popup which contains a button. When I click that button, then the page (inside the popup) gets redirected to a new internal page. What I want to achieve is that the pop-up should close after 1 second after the redirection has happened. I applied the function when the button is clicked which is only available before the "Popup Redirection".</p>

<pre><code>    $('.page-user-cancel .btn').click(function(e) {
    window.onunload = refreshParent;
    setTimeout( function(){
        function refreshParent() {
        window.opener.location.reload();
        window.close();
        }
    }  , 1000 );
}); 
</code></pre>

<p>If I am not clear, please comment. English is not my native language.</p>

<p><strong>EDIT</strong></p>

<p>If that is not feasible, is it possible to trigger the function when the div on the new page (after redirection) gets loaded?</p>

<p><strong>UPDATE</strong></p>

<p>This isn't working:</p>

<pre><code>var dival = $('.inside .alert').length;
if (dival &gt; 0){
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.location.reload();
        window.close();
        }
}
else{}
</code></pre>

<p>It works, only after refreshing.</p>

<p>Got it Worked: Had to remove the function call of refreshParent. might not be the best practice, but it is working that way.</p>