2

I have opened a window from another page. On button click, I want to close this window. However, the browser is complaining that "Scripts may close only the windows that were opened by it".

I tried:

window.open('', '_parent', '');
window.close();

but its not working. Please help.

TheLifeOfSteve
  • 3,060
  • 6
  • 33
  • 52
DfrDkn
  • 1,110
  • 1
  • 15
  • 21
  • possible duplicate of [window.close() doesn't work - Scripts may close only the windows that were opened by it](http://stackoverflow.com/questions/25937212/window-close-doesnt-work-scripts-may-close-only-the-windows-that-were-opene) – TheLifeOfSteve May 27 '15 at 13:33

1 Answers1

0

The below code worked for me

window.open('location of current page', '_self', '');
window.close();
Bhavesh Odedra
  • 10,294
  • 12
  • 30
  • 58
DfrDkn
  • 1,110
  • 1
  • 15
  • 21