Jump to content

[SOLVED] How do I open a new window, close the new window and refresh the parent window?


OM2

Recommended Posts

How do I open a new window, close the new window and refresh the parent window?

 

OK, let me clarify:

 

1. I have a page: page1.html.

This has a link to page2.html.

 

2. The link is clicked and page2.html pops up in a new window.

 

3. page2.html has a button that closes the window and gives the focus back to page1.html (while refreshing page1.html).

 

Hope that explains it properly!

 

How do I do this?

 

I wasn't sure if this involved Javascript?

 

So, I thought I'd try asking here.

 

Thanks.

 

 

OM

 

Link to comment
Share on other sites

It does involve javascript (which makes it unstable as many people have javascript turned off). Google window.open, and see what you find. You can trigger parent and child windows from the parent and child windows, so you can pass functions that way to change focus to the parent window and refresh the page.

Link to comment
Share on other sites

hmmm... i'm stuck on this one.

javascript: is there a non javascript way?

thanks for the reply.

 

i've looked into it and thought i had a solution (using javascript):

 

first page:

<a href="secondpage.html" target="_blank">Edit</a>

 

second page:

<SCRIPT language=JavaScript>

<!--

function win()

{

window.opener.location.href="firstPage.html";

self.close();

//-->

}

</SCRIPT>

...

...

...

<input type=button onClick="win();" value="Return">

 

1. Annoyingly, I get a warning box popup that says: "Hey, this button is trying to close this window, do you want to allow it?".

 

How can I stop this?

 

2. It doesn't actually go back to the parent calling window at all and refresh. :(

 

Link to comment
Share on other sites

First, you said you found this as a javascript solution:

 

<a href="secondpage.html" target="_blank">Edit</a>

 

This isn't javascript, it's html. So when you open the second window, there is no javascript reference to the first window. The second window is opened, but it is an independent window. You want to use the window.open command: http://www.devguru.com/technologies/javascript/10894.asp to open the second window. This will result in both windows containing a reference to each other.

 

1. Annoyingly, I get a warning box popup that says: "Hey, this button is trying to close this window, do you want to allow it?"

 

I believe that you can't get around this, though you may be able to by closing the child window from the parent window using javascript. It's been a long time since I played around with parent and child windows in javascript though, I prefer just to open a div overtop my content instead, and keep everything in one window.

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.