views:

12

answers:

1
<?php 
   if($_POST["some_variable"]){
       echo "this window should be closing now";
   }
?>

How would I call the JQuery code to close the window, and what would the function be?

The window was opened with a code resembling the following...

$('.new_window').each(function(){
        $(this).click(function(){
            var center   = 'height=436,width=465,top='+((screen.height - 436)/2)+',left='+((screen.width - 465)/2);
            var address = 'popup.php?fid='+$(this).attr('id');
            window.open (address,'new_window', center); 
        });
    });

I'm guessing the code goes somewhere inside my JS file, and is somehow called from within the "if" braces.

Some clarification: The php in my example doesn't really matter. The gist of the thing is, I need to close the window if the PHP code makes it to that code block. My database should also be updated before the window closes (not in the example code).

+1  A: 

This piece of Javascript should do the trick:

<script>
    window.close();
</script>
Piskvor
Thanks! I actually thought about using this, but I'm still new to web programming, and wasn't sure if I could run JS like that validly. It could be infinitely useful to use PHP and JS like this together.
serv-bot 22