Posted by: prajapatinilesh | September 14, 2007

Window.opener example

//p1.php
<html>
<head>This is head <title> this is title</title>
<script language=”javascript” type=”text/javascript”>
function open_it(){
//this opens a new window without toolbars, menubars, etc.
lovechild = window.open(“p2.php”, “lovechild”,”height=400,width=200,resizable=0,menubar=0,toolbar=0,location=0,directories=0,scrollbars=0,status=0″)
//this sets the opener of the first opened window to the new window you just opened
this.opener=lovechild
//this pauses, then closes the window you first opened
//setTimeout(“self.close()”,5000)
setTimeout(“lovechild.close()”,5000)
//lovechild.close();
}
</script>
</head>
<body onload=”open_it()”>
<form>
<center> this is my page </center>
<a href=”javascript:openPopupWindow(‘p2.php’,’test’);” >Click</a>
</form>
</body>
</html>
<script language=”javascript”>
function openPopupWindow(url,popupName) {
if (popupName && popupName != ‘undefined’) {
}
else {
popupName = ‘PopupName’;
}
//popupName
window.open(url, ‘test’ , “width=400,height=300,top=75,left=75,scrollbars=yes”);
} // END function – openPopupWindow
</script>

//p2.php

<html>
<head>This is head <title> this is title</title> </head>
<body>
<form>
<center> this is my page </center>
<?
echo ‘nilesh page2’;
?>
</form>
<a href=”javascript:;”
onclick=”opener.location.href=’http://www.google.com/'”>Link name …..</a>
<br>
<a href=”javascript:;”
onclick=”window.opener.open(‘http://www.google.com/&#8217;)”>Link name 1…..</a>
<br>
<a href=”javascript:;”
onclick=”javascript:goToParent();”>Link name 2 …..</a>
<br>
<a href=”http://www.google.com/&#8221;
onclick=”opener.foo=window.open(this.href,”,’width=300,height=300′);
return false;”>Link name 3 …..</a>
<br>
<a href=”http://www.google.com/&#8221;
onclick=”opener.foo=window.open(”,”,’width=300,height=300′);
opener.foo.location = this.href;
return false;”>Link name 4 …..</a>
</body>
</html>
<script language=”javascript”>
function goToParent()
{
var parentObj = window.opener;
oH = parentObj.outerHeight; //for mozilla
oW = parentObj.outerWidth;
parentObj.open(“p1.php”,’nilesh’,’width=’+oW+’,height=’+oH+’,scrollbars=yes’);
}
</script>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: