dhtmlXWindows is not centering

Hello,

I’m building a page and I’m using dhtmlXWindows, when I try to center the window within the screen it works fine on FireFox, however It dones’t center on IE, it shows the window at the center of the page which is screwed for long pages.
I tried to use both of center() and centerOnScreen() methods and both gives the same result, and center the window within the page not within the shown part of the page [screen].

Could you please help me to fix this?

Thanks,

Hello,

could you attach the sample to reproduce the problem locally ?

Hello,

Thanks for responding, here’s a sample of the code I’m using:

/* INIT Magic Form WINDOW */
dhxWins = new dhtmlXWindows();
dhxWins.zIndexStep = 100000;
dhxWins.attachEvent(‘onClose’, function(win) {
win.setModal(false);
win.hide();
return false;
});
winNewCampaign = dhxWins.createWindow(‘newCampaign’, 0, 0, 700, 420);

winNewCampaign.setText(‘New Campaign’);
winNewCampaign.denyResize();
winNewCampaign.denyPark();
winNewCampaign.attachObject(‘newCampaign’);
winNewCampaign.hide();

dhxWins.zIndexStep = 50;

winNewCampaign.setText(win_title);

AND to show the popup, I use the following code:

winNewCampaign.show();
winNewCampaign.centerOnScreen();
winNewCampaign.setModal(true);

AND I have also tried the following code, and it gives the same results:

winNewCampaign.show();
winNewCampaign.center ();
winNewCampaign.setModal(true);


Hello,

we need a completed demo:
docs.dhtmlx.com/doku.php?id=othe … leted_demo

Thanks for your response,

I have a testing page for you to test the issue, the demo is at this URL:

Note: The issue occurs only at IE.
To test the issue, please click the “Create” button at the center of any of the boxes.

Thanks,

Hello,

try to use the following approach to center window to consider scroll position.

winNewCampaign.center();
var pos = winNewCampaign.getPosition();
var offset =(document.body.scrollTop?document.body.scrollTop:window.pageYOffset);
winNewCampaign.setPosition(pos[0],pos[1]+offset);

I have deleted the link your demo.

Hello,

Thanks for responding,
I’ve tried the code you are providing, however it didn’t fix the issue,
Note: I’m using IE8 and it shows document.body.scrollTop is equal to zero all the time, and so the position of the popup doesn’t change.
Here’s the demo page again incase you want to check the code: app.leadliaison.com/window-not- … issue.html

Thanks,

Hello,

try more complicated approach:

winNewCampaign.centerOnScreen(); var pos = winNewCampaign.getPosition(); var height = document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight; var scrollPosition=(document.body.scrollTop?document.body.scrollTop:(document.documentElement.scrollTop?document.documentElement.scrollTop:window.pageYOffset))||0; winNewCampaign.setPosition(pos[0],height/2-210+scrollPosition);

here 210 is height of the window divided in half

Hello,

Thanks for responding, this worked on IE and FF and the issue is fixed.

Thanks very much… :slight_smile:

I followed this code and have the window centering properly, but the grayed out background is not properly covering the entire screen. See attached screenshot.


the grayed out background is not properly covering the entire screen

Try to attach the viewport to a div. It will solve the issue. Here are samples:

dhtmlxWindows/samples/01_init/07_attach_object.html
dhtmlxWindows/samples/02_viewports/03_render_as.html

Thanks, that helped!