PDA

View Full Version : How do you center an MM_openBrWindow?


salaroche
08-30-2010, 03:12 AM
Hi everyone:

I'm using the MM_openBrWindow behavior to display larger images of some thumbnails listed on a webpage. The behavior works fine for every instance, but the new browser window always opens on the left-hand side of the screen.

How can I make the new browser window open on the center of the screen?

Any suggestions will be much appreciated.

Thank you in advance for your attention.

Salaroche

edbr
08-30-2010, 03:31 AM
var myWindow;

function openCenteredWindow(url) {
var width = 400;
var height = 300;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
myWindow = window.open(url, "subWind", windowFeatures);
}

salaroche
08-30-2010, 03:49 AM
Hi edbr:

Thank you for your reply.

This is the relevant code generated by the behavior I'm talking about:

onclick="MM_openBrWindow('Products/Handbags/HandBagPages/SB-3165.html','SB3165','width=860,height=700')"

Would you know what code I could ad to make the browser window open in the center of the screen?

Thank you.

edbr
08-30-2010, 03:53 AM
you can position the window using top and left but to center t you will need a function
you need a function to divide the screen (- the window dimensions)

then call the function onclick

salaroche
08-30-2010, 03:58 AM
edbr:

Do you mean I would have to ad the portion of the code you sent embedded between the {...} brackets?

salaroche
08-30-2010, 04:02 AM
edbr:

If you wish you could view the site and see the behavior in action.

http://www.sbhandbag.com/HandBags.html

It's a website I'm designing for a friend

Thanks

edbr
08-30-2010, 04:07 AM
no you have to call the different function,
ok check this link its a better one and explained how to implement