Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to generate a pop up window to display some information.

As an example i have a name list and when i click on it i need that popup window.
Next scene is when i click on the next link the first pop window should aut o close and second pop up window should open. how can i do that.

Below i post my code.

XML
<script language="javascript" type="text/javascript">
function popitup(url) {
    newwindow=window.open(url,'name','height=200,width=150');
    if (window.focus) {newwindow.focus()}
    return false;
}
</script>
<body>
<a href="a1.html" onclick="return popitup('a1.html')"
    >asdfgh</a>
Posted

1 solution

Hi there,

i guess this is what you want (old popup is closed from parent-side
if new popup is desired):

Javascript:

<script type="text/javascript">

      var currentPopup = null;
      function popitup(url)
      {

          if (currentPopup && currentPopup.open && !currentPopup.closed) {
              currentPopup.close();
          }

          currentPopup = window.open(url, 'name', 'height=200,width=150');

          if (window.focus)
          {
              currentPopup.focus()
          }
      return false; }

  </script>




Html:
 <a href="#" onclick="return popitup('test.htm')">Link1</a>
<a href="#" onclick="return popitup('test.htm')">Link2</a>
 
Share this answer
 
Comments
Strider1987 18-Sep-10 3:26am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Strider1987 18-Sep-10 3:27am    
ty m8.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900