joemorris86 Posted August 20, 2011 Share Posted August 20, 2011 I was using the following code to close my popup window <a href="java script:self.close()">Close window</a> and I wanted it to refresh the parent page when Close window was clicked.I found this example, which works but it automatically closes my popup rather than letting me click on Close window.Does anyone know how I can make this code only close and reload my parent page when I click the close link ? window.close();if (window.opener && !window.opener.closed) {window.opener.location.reload();} Thanks guys Link to comment Share on other sites More sharing options...
Drycodez Posted August 20, 2011 Share Posted August 20, 2011 Function refresh() {[codes] } Put the code inside a function! Link to comment Share on other sites More sharing options...
joemorris86 Posted August 20, 2011 Author Share Posted August 20, 2011 Do you mean something like this? sorry This is the first javascript I have ever done so Im a bit clueless. This doesn't close my popup. <script language="JavaScript"><!--function closerel() { window.close();if (window.opener && !window.opener.closed) {window.opener.location.reload();}//--></script><a href="java script:closerel()">Close window</a> Link to comment Share on other sites More sharing options...
Drycodez Posted August 20, 2011 Share Posted August 20, 2011 <script language="JavaScript"><!--function closerel() {if (window.opener && !window.opener.closed) { window.close(); //insertwindow.opener.location.reload();}//--></script><a href="java script:closerel()">Close window</a> Link to comment Share on other sites More sharing options...
joemorris86 Posted August 20, 2011 Author Share Posted August 20, 2011 That seems to try and redirect my page to http://mysite.com/java script:closerel() Link to comment Share on other sites More sharing options...
Drycodez Posted August 20, 2011 Share Posted August 20, 2011 <a href=" java script:closerel()">close window</a>make sure you remove the space between the word (javascript) marked in red! Link to comment Share on other sites More sharing options...
ShadowMage Posted August 22, 2011 Share Posted August 22, 2011 You're also missing a closing '}' on your function. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.