1

I've 2 php files: home.php & another_page.php

home.php :

<li><a href="another_page.php">Page2</a></li>

another_page.php:

$('#exit_button').click(function() {
   window.close();
});

The If i navigate from home.php to another_page.php and press click exit button then it does not close the window!!!

How ever if i modify the home.php anchor links

<li><a href="another_page.php" target="_blank" >Page2</a></li>

After the above change the code works fine.

But i want to do it without opening the 2nd page in new tab.I tried with

parent.window.close(); OR window.open('', '_self', '', ''); window.close();

But didn't worked.please help me.

user5005768Himadree
  • 1,375
  • 3
  • 23
  • 61
  • 2
    Maybe this [answer](http://stackoverflow.com/a/14373670/1022914) relates to your question. However, based off [comments](http://stackoverflow.com/questions/2076299/how-to-close-current-tab-in-a-browser-window) on this post, I doubt what you are trying to accomplish can be done with today's modern browsers. – Mikey Oct 23 '16 at 08:20
  • Check your console. In chrome, it says : *«Scripts may close only the windows that were opened by it.»* – Louys Patrice Bessette Oct 24 '16 at 18:23
  • Possible duplicate of [Close Current Tab](http://stackoverflow.com/questions/14373625/close-current-tab) – Louys Patrice Bessette Oct 24 '16 at 18:24

0 Answers0