• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Close a popup window

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to close a popup window which was opened by a page's link,the application needs to close that window while the back(its a link not browser's) button is clicked.
I have given the javascript here,but when i try to click the back button it closes the current window instead the popup window,can any one give me the solution how to do it.
Thanks in advance.
Syam.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of using an <A> tag, try using a button. Inside the onClick even handler you can get a reference to the popup window. Then later, if you need to close it you can just call close on that window.
 
Syam Veerakumar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply but I have to use the <A> tag here, so cud u pls give me any other solution.
Syam.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Syam,
I think I may be of help to you in this regard.
Declare a global variable for holding the window object of the popup window. In the hyperlink tag, give javascript:functionName() for href attribute. That is it. The skeleton of the code may look like this.

var myWin;
<a href='javascript:myOpen()'>open popup</a>
<a href='javascript:myclose()'>close popup</a>

function myOpen(){
myWin= window.open(...);
}
function myclose(){
mywin.close();
}
Pretty nice ! Isn't it.
Well, do let me know, if you need any further clarifications.

S.Mohamed Yousuff

Originally posted by Syam Veerakumar:
Thanks for the reply but I have to use the <A> tag here, so cud u pls give me any other solution.
Syam.

reply
    Bookmark Topic Watch Topic
  • New Topic