How to get the windows ID


#1

It’s possible to return in the window, the window ID?

This is a part of the code that create the Windows:

dhxToolbar7 = tabbar.cells("c9").attachToolbar();
dhxToolbar7.setIconsPath("dhtmlx/dhtmlxMenu/samples/common/imgs/");
dhxToolbar7.addButton("New", 1, "Crea nuovo operato...", "page_white_add.png", "page_white_add.png");
dhxToolbar7.attachEvent("onClick", function(id) {
if(id=="New") {
createWindow('Operato_add.php?CID=<? echo $_GET["CID"]; ?>','Aggiungi operato','500','372','yes');
w1.allowResize();
}
});

Now in the opened page i want too display that this is the window with ID w1, is this possible?


#2

There is a method of getting window’s ID getId():
docs.dhtmlx.com/doku.php?id=dhtm … sngl_getid


#3

I’m using this script:

<script>
dhxWins = new dhtmlXWindows();
var idPrefix = 1;
/*
- url= address
- title: titol of the window
- w: width
- h: height
- r: is resizable?
*/

function createWindow(url, title, w, h, r) {
	var p = 0;
	dhxWins.forEachWindow(function(){p++;});
	if (p>=5) {
		dhtmlx.message({
			title:"Important!", 
			type:"error", 
			text:"Not more than 5 windows are allowed"
		});
		return;
	}
	var id = "userWin "+(idPrefix++);
	var win = dhxWins.createWindow(id, 20, 50, w, h);
	win.setText(title);
	var winId= dhxWins.window(id)
	dhxWins.window(id).center();
	win.button("park").hide();
	win.button("minmax1").hide();
	win.attachURL(url);
	dhxWins.window(id).keepInViewport(true);
    if(r==0){win.denyResize();}
};
</script> 

Now I have 2 questions:

  • on the created window how can I get the id of the page, the getId() function don’t works :angry:
  • if the created window (window 2) is created on the parent (parent.createWindow(…) from another window (window 1) is there a way to obtain in window 2 the id of the first window, if the window would be created on the window 1 this window would be the parent, but in this case it’s not the parent but like a sister :stuck_out_tongue:

#4

Please, try to use:

dhxWins.forEachWindow(function(window){
    var id = window.getId();
});

It returns the id of the window well for me.


#5

I’m back again!!

But where I have to place this code. I have 3 files:

  1. is the “start file” in which i open the window using the createwindow.php file with a script like: onclick=’ parent.createWindow(“test.php?ID=1”,“Incassa conteggio commissioni”,450,280,0);"
  2. is the createwindow.php file that is fundamentally the script that generates the windows (see code on the first page
  3. the test.php file that is the file loaded in the window and it’s inside the window that I have to get the windows ID, so that I can for example change the size of the window, or the name, or simply close it.

And inside of the window the getID don’t work

As example here a code that I would like to use inside the window:

parent.dhxWins.window(******).setText(‘New page name’);

The ****** should be the ID that I have to retrieve inside the window, because i could also have more than one window.


#6

Do you want to get the id of the window inside the iframe attached to that window? You may send the id of a created window as a parameter of an url to a content of that window and get it wen it needed from the url window.location.search


#7

Thany you Semantik, I hoped that it was a simplier solution :slight_smile: