By Sergey Skudaev
I show you how to create a modeless popup and pass $_GET parameters from a parent page to the popup page. I use PHP and JavaScript to make it possible. JavaScript modelessparam function creates a modeless popup. Then in the URL you pass parameters and read them in popup page.
This is a script for main page:
parent.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Pass params to modeless popup</TITLE>
<?php
$param1="Hello There!";
$param2="Hi World!";
?>
<script language="JavaScript" type="text/javascript">
function modelessparam(url,width,height){
if (document.all&&window.print) //if ie5
eval('window.showModelessDialog( url,"","help:0;resizable:1;dialogWidth:'+width+
'px;dialogHeight:'+height+'px")')
else
eval('window.open(url,"","width='+width+'px,height=
'+height+'px,resizable=1,scrollbars=1")')
}
</script>
</head>
<body>
<p align="center"><input type="button" name="greeting" value="Open Popup"
onClick="javascript:modelessparam(
'http://yourdomain/popup/popup.php?param1=<? echo $param1;
? >¶m2=<? echo $param2; ?>',300,200)"></p>
</form>
</body>
</html>
This is a script for popup page:
popup.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Popup with param from parent window</title>
<?
if(isset($_GET['param1']))
$param1 =$_GET['param1'];
if(isset($_GET['param2']))
$param2 =$_GET['param2'];
?>
</head>
<body bgcolor="#996699">
<?php
print('<p style="align:center; font-size:40px; color: #000;">'. $param1.'</p>');
print('<p style="align:center; font-size:50px; color: #000;">'.$param2.'</p>');
?>
</body>
</html>