2

I have one html page (static html). Inside that I have anchor tag (.windowOpener), and a hidden div(.status) which shows the status. When user clicks the anchor tag, a window gets opened:

     <a href="#" class='windowOpener' onClick="window.open('newPage.html','New Page','resizable,height=580px,width=357px'); return false;">Click here</a>
<div class='status' style='display:none'>Successful</div>

On click of this link, a separate window gets opened. In this new window, there is one link as

<a class='paymentButton' href='javascript:void(0)'>Do the payment</a>

Now on click of this anchor tag (.paymentButton), I want to close the new window and want to make the 'status' div visible in the first window. I don't want to use the modals.

Is it possible to do this? Any help will be appreciated...

Thank you in advance.

Patryk Rudnicki
  • 687
  • 1
  • 9
  • 20
Shruti Jog
  • 49
  • 3

1 Answers1

2

Use window.parent to access the parent window:

$(document).on('click', '.paymentButton', function() {
    parent.showStatusDiv();
});

And declare showStatusDiv() function in the parent window:

function showStatusDiv() {
    $('.status').show();
}

NOTE

In case of more that one level of windows, use window.top to access the top most window

kapantzak
  • 11,328
  • 4
  • 38
  • 59
  • thank you @kapantzak for your suggestion. somehow it is not working. I tried with parent.showStatusDiv(); and also with window.parent.showStatusDiv(); But it is giving me error as: Uncaught TypeError: window.parent.showStatusDiv is not a function pl note that i am not using any iframe – Shruti Jog Oct 15 '18 at 10:35