Hide or close the browser tab when its inactive using native javascript?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Why do you want to do this? If you could hide/close inactive tabs, how would you switch ti another tab (apart from <ALT><TAB> keystroke) - there would not be any tabs to switch to. Have you thought this through?

Why do you want to do this? If you could hide/close inactive tabs, how would you switch ti another tab (apart from <ALT><TAB> keystroke) - there would not be any tabs to switch to. Have you thought this through?

Because I need this to my current project that I doing right now. I want to automatically close/hide the browser tab if the user is switch into another tab or tab is inactive. Will you please help me? I search and reading lot of questions and articles about this topic but no update answer

Sorry I can't help, I'm not a JavaScript coder. It just occurred to me that the concept was potentially flawed anyway... Have you seen anywhere where this functionality is implemented? If so, you should <ctrl>U or <ctrl>P the page and study it. That, or at least give us a link to it, so we can see the functionality you are seeking to implement...

By the way when you say "hide" do you mean that the tabs will automatically display when moused over? If so:
1. That is very different from closing the tab.
2. What about mobile users (who do not have hover functionality)?

By the way, I appreciate that I may be asking questions that are not directly relevant to the task you have been set. However, thinking around the objective could lead to a better solution than focusing simply on the task as set...

Wouldn't opening a new web page with a reference in the opener to test if the page opened and loaded then self close the page that opened the new page work?

I have to agree, that kind of functionality doesn't seem to have any legitimate purpose.

STOP using $ prefix on JavaScript variable names...
Please remember to wrap any code you have in forum tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...