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,208
  • 6
  • 37
  • 53
DfrDkn
  • 1,270
  • 2
  • 16
  • 23
  • 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,990
  • 12
  • 33
  • 58
DfrDkn
  • 1,270
  • 2
  • 16
  • 23