Skip to main content

Popup with adjustable size + centering on screen PLEASE HELP!

No replies
pokinski
Offline
Joined: 2006-02-17

Hi,

I really don't know very much about Java script until now, as I just use paragraphs of code 'copy&pasting' them to my site. My problem is the following.

On my startpage I have an 'if' loop implemented, that opens a popup window in a certain size, according to the screen resolution the computer uses.

However what I want is, that the window opens centered as well. How do I amend the code so that it works. At the moment the code looks like this:

function MM_openBrWindow(theURL,winName,features) { //v2.0
if (screen.width > 1000)
window.open("folio.htm", "_blank", " left=5,top=5,width=1003,height=639,toolbar=0,menub
ar=0,location=0,status=0,resizable=0,scrollbars=0");
else if (screen.width < 1020)
window.open("folio2.htm", "_blank", " width=780,height=500,toolbar=0,menubar=0,location=
0,status=0,resizable=0,scrollbars=0");
}
//-->

function winOpen(url, breite, hoehe) { // Errechnet Koordinaten, um das Popup zentriert zu platzieren
links = (screen.width/2)-(breite/2);
oben = (screen.height/2)-(hoehe/2);
window.open(url,"popup","height="+hoehe+",width="+breite+",status = no,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no,scrollbars = no,fullscreen = no,top ="+oben+",left ="+links);
}
//-->

Please help me. I'm so lost...
Matt