window.close problems

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

window.close problems

Post by shiznatix »

I am trying to close a popup with window.close() but it is being silly. Here is the whole scoop:

I open a popup. I think have the user fill out a form and when they click submit it calls a javascript function and sends the data through ajax. If we get the correct response from ajax, I try to do window.close();

The problem is that the window will not close until I click somewhere else on the window. If I click on the window anywhere else, the window.close will run and actually close the window. How can I make it just close the freakin window right away?

Here is my code:

Code: Select all

reqsend.onreadystatechange = function()
{
    if (reqsend.readyState == 4 && reqsend.status == 200)
    {
    	response = reqsend.responseText.split(":");
    	
    	if ("-1" == response[0])
    	{
    		alert(response[1]);
    		return false;
    	}
    	else if ("1" == response[0])
    	{
    		window.opener.document.location.href = "'.ADMIN_ROOT.ADMIN_DIRECTORY.'/raketracking_usermap/'.$usermap_id.'/'.($show ? '?show='.$show : '').'";
    		window.opener = self;

			window.close();
			return true;
    	}
    }
};
Really, I just want to do window.close() and then do the equivilant of the die() command.
Post Reply