OM2 Posted July 30, 2008 Share Posted July 30, 2008 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 Quote Link to comment Share on other sites More sharing options...
haku Posted July 31, 2008 Share Posted July 31, 2008 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. Quote Link to comment Share on other sites More sharing options...
OM2 Posted July 31, 2008 Author Share Posted July 31, 2008 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. Quote Link to comment Share on other sites More sharing options...
haku Posted August 1, 2008 Share Posted August 1, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.