<?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).
This piece of Javascript should do the trick:
<script>
window.close();
</script>
精彩评论