Jump to content

[SOLVED] Open a new window in the previous window & closing the current window


playaz

Recommended Posts

Hi guys,

 

This is probably really simple but I am not sure how it is done.

 

Basically, I have a page (page 1) that has a standard text link that when the user clicks the link opens this in a new pop-up window (page 2) - in the new window when the user clicks a link it should close the pop-up and load this new URL in initial page (page 1).

 

So in simple terms, page 1 is always there, while page 2 closes itself when a link from within page 2 is clicked..

 

Any ideas or code on how I can achieve this?

 

Thanks in advance

Link to comment
Share on other sites

Hi guys,

 

This is probably really simple but I am not sure how it is done.

 

Basically, I have a page (page 1) that has a standard text link that when the user clicks the link opens this in a new pop-up window (page 2) - in the new window when the user clicks a link it should close the pop-up and load this new URL in initial page (page 1).

 

So in simple terms, page 1 is always there, while page 2 closes itself when a link from within page 2 is clicked..

 

Any ideas or code on how I can achieve this?

 

Thanks in advance

page 1

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function open_window()
{
window.open('2.html','pwindow','status=1');
}
</script>
</head>

<body>
<a href="javascript:open_window()">Open Popup</a>
</body>
</html>

 

page2

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function open_window()
{
window.opener.document.location.href="http://www.google.com";
window.close();
}
</script>
</head>

<body>
<a href="javascript:open_window()">Open page in parent window</a>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.