PDA

View Full Version : javascript on window close



l_kris06
02-12-2009, 03:50 PM
To many here, this would be a simple issue, but am new to Javascript and I dont knw how to go about it.

This is what i have:

a) A window pops up from a page, and user does some posting/uploading/adding operations(PHP), all involve refreshing this newly opened window.

what i want is , when the user closes this new pop up window(by clicking on the RED 'X' at the top) i want the parent window to be refreshed.

This is what i have(new pop up window) :


<script>
function ref(){
window.opener.location.reload(true);
window.close();
}
</script>
<body onunload="ref()">
</body>

This is wht i want, but the problem is , everytime the child window refreshes, child window gets closed and the parent window is refreshed. I want this 'close and refresh' behavior to happen only when the window is closed(through the RED X at the top right of the window ONLY).

Any help would be great.

Best,
Kris

l_kris06
02-12-2009, 03:58 PM
Ok, found the fix. The fix is to simply remove the
window.close(); line.!!