javascript - How to close the Current opened Tab and go back to previous (Parent) Tab - Stack Overflow

It is not a duplicate question please Dear All,I am new to Jquery, Please help me how to close the Cu

It is not a duplicate question please Dear All, I am new to Jquery, Please help me how to close the Current opened Tab in a application using Jquery on click of YES/Confirm button in a model window as shown in a image. I have tried below function, its not closing current tab instead it closed all the tabs. Please help me

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

It is not a duplicate question please Dear All, I am new to Jquery, Please help me how to close the Current opened Tab in a application using Jquery on click of YES/Confirm button in a model window as shown in a image. I have tried below function, its not closing current tab instead it closed all the tabs. Please help me

window.open('', '_self').close();
         window.top.close();
         window.close();
Share Improve this question edited Mar 14, 2019 at 0:58 Barmar 784k57 gold badges548 silver badges659 bronze badges asked Mar 14, 2019 at 0:46 ShankarShankar 711 silver badge7 bronze badges 5
  • JavaScript can't manipulate tabs. – Barmar Commented Mar 14, 2019 at 0:58
  • Since i am opening the window/tab not using window.open so. I am able to close the particular tab by TabID using programmatically – Shankar Commented Mar 14, 2019 at 15:54
  • JS can only close a window/tab that it opened. If you don't use window.open, you can't close it. – Barmar Commented Mar 14, 2019 at 15:56
  • I am able to close the particular tab by TabID using programmatically You keep stating that, but it's not true. Why do you think you're able to do that? Where do you get the TabID from? – Barmar Commented Mar 14, 2019 at 15:58
  • I think a browser extension can do this, but not JavaScript in an ordinary page. – Barmar Commented Mar 14, 2019 at 15:58
Add a ment  | 

2 Answers 2

Reset to default 2

before you close the current tab, you need to open it using "window.open()". the window.close button works only the windows that opened by it.

You can close the current tab with this javascript line:

window.top.close();

But there are things that you should keep in mind:

  • This will only work if the tab is also opened programmatically.

    By using window.open();, you can close the opened tab with the javascript line above.

  • Not all browsers support this solution

You can also visit this link for reference. I hope this helps.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745364789a4624526.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信