I use this script to close the current page and refresh its opening parent page:
window.opener.location.href = window.opener.location.href;
But now I need to be able to use the same page without being opened by its parent page. It should also be used by clicking a link to it in an e-mail. In this situation the current script does not close the page because it has no parent page.
Can I make the script smart enough to know it has a parent page or not?