Click to See Complete Forum and Search --> : Return from Pop-up Window
Grobius
10-04-2003, 12:52 PM
I am using a pop-up window as a sub-menu, but when I click on a link in that window, the new page opens within the pop-up menu. I can by-pass this by specifying target="_new" in the links, but that opens up a new browser window. What I want to do is have the link appear in the original window underneath the pop-up, from which the pop-up was invoked. I know there is a Javascript property called "opener", meaning the original window, but I can't make any script work to achieve this. Any ideas, anybody?
opener.location.href="page.html";
// or
parent.location.href="page.html";
[J]ona
Grobius
10-06-2003, 09:37 PM
That doesn't work -- in fact nothing happens at all!
Here is the script I used:
<script language=javascript>
function goBack(newpage) {
opener.location.href=newpage;
}
</script>
And here is the link:
<a href='#' onClick="goBack('http://www.page.htm');">Page to Show</a>
Is the problem that MSIE does not recognize 'onClick' for a link, only for an Image?
Charles
10-06-2003, 09:56 PM
The trick is in keeping the site working for those who do not use JavaScript and for those who close the parent window.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<p><a href="test2.html" onclick="window.open(this.href, 'child', 'height=400,width=200'); return false">test</a></p>
And
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<p><a href="http://www.w3.org/" onclick="if (window.opener) {opener.location = this.href} else {window.open(this.href)}; return false">test</a></p>