Dear all,I need coding for closing a pop up window, I wrote a separate button to close the window, What i need is if i click the close in window, it should call the same function that i wrote for button clicking.the code i wrote is<script language="javascript"> var winobj; //window.onunload=displayMessage; winobj = window.self; window.onunload=displayMessage; function displayMessage() { document.write('<p style="display:none;"><FORM action="main.php" name="logout" method="post" target="_parent">'); document.write('<INPUT type="hidden" name="session_id" value="<?=$session_id?>">'); document.write('<INPUT type="hidden" name="include" value="9">'); document.write('<INPUT type="submit" class="buttons" value="<?=$lng["logout"]?>">'); document.write('<FORM></p>'); document.logout.submit(); alert('You are Quiting CramLIVE now...'); winobj.close(); } </script>please find solution.