PDA

View Full Version : DHTML Window Widget: Close Window-Layer(s) While Opening Another



twohawks
10-05-2007, 11:42 PM
1+2) Script Title and URL (on DD):
DHTML Window widget (v1.03) (http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm)
Thank you for this nice and very useful piece of work ;^)

3) Describe problem: How to Close an already opened window layer, or several, in/with the opening action of a particular link, without having to reference the already open window(s) uniquely (like by uniqueID)?

4) Details:
I am using ajax. I tried using "ajaxwin.hide()" command in my event controls, but this doesn't always work and it gets messy.
I was hoping to be able to insert some sort of code [elsewhere] into the dhtmlwindow.js file, probably under the open function, to simply globally control things so only one window is ever open at a time.
Or better yet, place/build some code elsewhere in the js file so link code (in the html doc) can "choose" whether or not it wishes other window-layer(s) to be closed.

What I finally ended up doing is to simply reuse the uniqueID for links I created so that they reuse the same window layer.
This gives the illusion of the effect.
However, as well as this seems to work (for now anyway) I am uncertain if this is the best solution or even good to be doing??
Wouldn't it be better to be able to choose to specify in a link that, when clicked, 'it looks' to see if any other window-layers are present and if so, closes them (without having to know the specific id of each open window layer)?

Cheers,
TwoHawks

ddadmin
10-06-2007, 10:45 AM
Inside dhtmlwindow.js, try adding the code in red to the existing function:


open:function(t, contenttype, contentsource, title, attr, recalonload){
for (var i=0; i<this.tobjects.length; i++){
if (this.tobjects[i]!=t)
this.tobjects[i].hide()
}

This should work in general cases as far as closing all other windows (if any) before showing the current.

twohawks
10-06-2007, 07:03 PM
Most excellent - that appears to address the issue succinctly.
Thank you!