Create a dhtmlXWindow if it doesn't exist yet

Hey there

I’ve set up a nice way to display a map on a site using dhtmlXWindow, but I’m experiencing an annoying issue :

I have four links on the page that are meant to open a map, showing different locations, in a dhtmlXWindow using attachURL.

Currently, each time the user clicks on one of those links, a new dhtmlXWindow opens showing the corresponding map, even if there was one or more already opened. The user can’t tell because I use a fixed position and move/resize are disabled, but there can a whole pile of maps hidden beneath the one that is visible.

What I’d like is this :

User clicks on one of the links : if no dhtmlXWindow exists yet, then one is created, displaying the requested map. Then if the user clicks another link without closing the existing one, the requested map is being displayed in the existing dhtmlXWindow.

I tried to set this up but my limited js skills prevent me from doing it right

Any help would be greatly appreciated on how to achieve this result.



you can try to use dhxWins.window(winId) to check if window exists or not:

dhxWins = new dhtmlXWindows();

var win = null
function openWindow(url){
win = dhxWins.createWindow(“w1”, 20, 30, 320, 240);

Works like a charm !

Thanks you so much !