Hello. I am trying a new programming technique for me. I have a website, where I keep the parent window open, and have a few buttons that open up java-script popup windows. I use a separate .js file to contain all of my java-script, and load it up as an include file. This works great. All the windows needed popup, and i can control them as far as opening them up etc. However, the issue is when I use the log-out function, I want to be able to destroy my php session and close down all the popup windows that might be open. Here is the function in my menu to open the popups, which works:
I do it this way because I need to keep the pop-ups open and separate without overwriting each window. The user can manually close the popup if they need to, but I have other plans for the popups as well.
Here is the java-script code that does the functions:
Now I have researched how to close all pop-up windows at once, and have become confused. My need is to destroy the php session, which I know how to do, and then close any open pop-up windows. I know how to close an individual popup window from inside the window by using the window.close() function, but how do I close all windows from a separate function, and then redirect the parent window back to itself? I use a javascript redirect of:
Unmess you give the popul windows names in the JavaScript you will have no way to reference themfrom the JavaScript to be able to close them from JavaScript.
Perhaps the easiest way to handle it since all you want to be able to do is to close all the open ones is to assign them all into an array as they are opened. You can then simply close all the windows in the array when you need to.
uhm.. Ok, not sure how to assign them all to an array. But, on the other hand, how and where do I give them names, and, how do I close a window using a name?
Ok, I see your reply and understand. However, I need to know which sections each set of code needs to modify. var openWins = []; goes in which section? I assume the function code is modified in my java-script section. And I think the closing code must go into my java-script on my closing log-out form?
openWins is not currently available to the script that is run from your final php page.
Just speculating, but in the pop-up that is used to logout:
Code:
keepOpenWins = opener.openWins; // storing the variable (globally) from the main window
then in your PHP script:
Code:
<script type="text/javascript">
var kept = opener.keepOpenWins;
for (var i = kept.length-1; i >= 0; i--) kept[i].close();
</script>
I'm speculating (a little..) though, as I haven't had a chance to test this - and it's late.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW<== Let me see if I can wrap my head around what you just suggested. I know more of PHP and html and css, but java-script is new to me. Thank you let me see what I can do with what you wrote...