Ho creato innanzitutto delle funzioni JavaScript per calcolare le dimensioni (altezza e larghezza) del popup e per aprire i vari popup:
Codice PHP:
function GetPopUpWidth(size)
{
scr_width = screen.width;
if (size == "small") {reduct = 0.3;}
if (size == "medium") {reduct = 0.5;}
if (size == "large") {reduct = 0.7;}
popup_width = scr_width * reduct;
popup_width = Math.round(popup_width);
return popup_width;
}
function GetPopUpHeight(width)
{
popup_height = width * 0.77;
popup_height = Math.round(popup_height);
return popup_height;
}
function OpenPopUp(mypage, myname, w, h, scroll)
{
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+', width='+w+', top='+TopPosition+', left='+LeftPosition+', scrollbars='+scroll+', resizable'
return window.open(mypage, myname, settings)
}
Questo invece il codice della pagina chiamante:
Codice PHP:
<html>
<head>
<title>Home Page</title>
<meta HTTP-EQUIV="Refresh" CONTENT="60">
<script language="JavaScript" src="javascript/funzioni.js"></script>
<script language="JavaScript">
<!--
popup_w = GetPopUpWidth('small');
popup_h = GetPopUpHeight(popup_w);
-->
</script>
</head>
<body>
...
[url="javascript:void(0);"]Apri popup[/url]";