...

View Full Version : Centering a popup help



kovalik
08-21-2002, 04:59 PM
I know this is rather basic, but I have a script that I am using to open a pop up once a browser session. I would like to modify it to open the window in the center of the screen instead of top left

<script>
function openpopup(){
var popurl="jetdry.html"
winpops=window.open(popurl,"","width=200,height=190,")
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function loadornot(){
if (get_cookie('poppedup')==''){
openpopup()
document.cookie="poppedup=yes"
}
}

loadornot()
</script>

Thanks to anyone who has time to help:o

Skyzyx
08-21-2002, 05:13 PM
Try this to open a centered popup window...



<script>
function openpopup()
{
var popurl="jetdry.html"

zWinWide=200; // Configure for popup window's width
zWinHigh=190; // Configure for popup window's height

zAttrib=''; // Configure for popup window's attributes (noresize, scrollbars=no, etc.)

zScrWide=screen.width; // Leave me alone.
zScrHigh=screen.height; // Leave me alone.

zLeftPos=(zScrWide/2)-(zWinWide/2); // Leave me alone.
zTopPos=(zScrHigh/2)-(zWinHigh/2); // Leave me alone.

winpops=window.open(popurl, '', 'width=' + zWinWide + ',height=' + zWinHigh + ',left=' + zLeftPos + ',top=' + zTopPos + ','+zAttrib);
}


function get_cookie(Name)
{
var search = Name + "=";
var returnvalue = "";

if (document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);

if (offset != -1) // if cookie exists
{
offset += search.length;
// set index of beginning of value

end = document.cookie.indexOf(";", offset);
// set index of end of cookie value

if (end == -1) end = document.cookie.length;

returnvalue=unescape(document.cookie.substring(offset, end));
}
}

return returnvalue;
}


function loadornot()
{
if (get_cookie('poppedup')=='')
{
openpopup();
document.cookie="poppedup=yes";
}
}

loadornot()
</script>

kovalik
08-21-2002, 05:19 PM
Thank you very much for your time! It works like a charm.

kovalik



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum