0

I have a Php document where after executing a query it will need to close the page.

My problem is that I cannot close the page.

I tried using javascript window.close(); but that does not work.

I also tried using simulated key press(that is using control + w to close the tab) but was unsuccessful in making it work.

Umar
  • 1
  • 1
  • 4
  • 1
    Some windows cannot be closed, depending if they were opened by the `Window.open()` method or not. Was the window opened by a script? See the MDN Documentation: https://developer.mozilla.org/en-US/docs/Web/API/Window/close – insyri Oct 19 '21 at 11:20
  • Hi, `window.close()` or just `close()` have to work. Could you provide a piece of your code please? – Adrian Zavis Oct 19 '21 at 11:21
  • echo ''; – Umar Oct 19 '21 at 11:23

2 Answers2

1

You can use

window.open('', '_self', '');
window.close();
naxsi
  • 602
  • 3
  • 15
1

I remembered this from a another post. javascript close current window

window.open('','_self').close()

Chrissy
  • 11
  • 1