Open popup, click link, open in parent window, close popup?
I need help please. What I want to do from my page is to open the popup for which I am using this:
<a class="txt-button" onclick="javascript:void window.open('http://mypage.com/1/index.html','','width=700,height=500,resizable=false,left=0,top=0');return false;">Buy Now</a>
When the popup link is clicked, I want to open it in the main window and close the popup.
I've tried a lot of things and can't get it to work: --(
source to share
Use the object to access the main window opener
from the pop-up windowwindow.opener
. You can access any opening property, or even call a function call (if the domains match, as @N Rohler pointed out in the comment to your question), for example to navigate through usage window.opener.location.href
. Then you close your popup with the window.close();
following:
<a href="JavaScript:void(0);" onclick="openInParent('http://example.com/');">
click me
</a>
<script>
function openInParent(url) {
window.opener.location.href = url;
window.close();
}
</script>
source to share