Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript - Can javascript run while a browser tab is not in focus?

I for some JavaScript code that execute per second. However it doesn't seam to run if the tab it is loaded on isn't selected.

Is this my code or is Javascript not capable of does it?

Also, if Javascript can run when it's tab is not selected could someone help me with the code to determine with it's parent tab is select or not.

Answers can be in pure Javascript or JQuery and solution will only need to work in IE7+

Thank you in advance.

I'm working on get the some code for you to look at. Cheers.

Seams there was an error in the code. Thanks for the knowledge that javascript will run though.

like image 477
Ash Burlaczenko Avatar asked Nov 08 '10 11:11

Ash Burlaczenko


People also ask

Does JS run in background tabs?

Save this answer. Show activity on this post. For Windows Phone: tabs that are in the background are not given access to resources - so Javascript will not be running.

Can JavaScript run outside of browser?

You can run JavaScript console in terminal or any command-line interface using Node. js, an open-source, platform-agnostic runtime that executes JavaScript outside a web browser.

Can JavaScript access other tabs?

You can access the new window/tab if it was opened with JavaScript and the page indeed is in the same domain. var win = window. open("/path_to_page"); Then you'll have to wait for the page to load before you can access e.g. the title.

How does Tab work in JavaScript?

The file, tabs. js, contains the JavaScript that makes the tab navigation work. The tab navigation script basically does two things: it changes the stacking order or z-index of the elements and changes the background color and textcolor of the tab. This is done by simply changing the style property values of elements.


1 Answers

Javascript should be running at the background. For browsers except Google Chrome, each tab is a thread and tabs should be able to communicate with each other too. For the chrome case, since every tab is a process, you may need to use inter-process methods for communication.

If you could provide your code we would be more helpful.

like image 98
Skr Avatar answered Oct 02 '22 21:10

Skr