I am able to get the xml page in a new window. Now the problem is this: The new page will be displayed before the pop window(ie, the open , save,cancel window) actually comes. so if the user clicks on the save or cancel button, the new page is still present.  How to dispose the opened page if the user clicks on save or cancel button?

Actually when you click the master page's button that time itself the pop window is popping up.. When that page is been loaded since in that page header we are appending the content the download window is popping out. At that time if am canceling or even if am saving the content the opener pop window is still there. I want to kill that window in case of cancel or save.
 
Is there any work-arounds to achieve it by code?
 
Please help