Search code examples
javascriptwindowbootstrap-modal

Javascript close modal of another window


Is it possible to close another window modal?

var ws=window.open('/Views/View2','View two');

$(ws.document.getElementById('IdleEnd')).modal('hide')//not executing

I changed the html of other window modal, but unable to close

$(ws.document.getElementById('IdleEnd')).html('new content');

Solution

  • I bet jQuery .modal only works when the $ being used is on the same window that the .modal is being called on. Assuming the other window has jQuery as well, try:

    ws.$('#IdleEnd').modal('hide');