The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Stop JavaScript when tab in background
denmarks
post Dec 4 2021, 11:54 AM
Post #1


Advanced Member
****

Group: Members
Posts: 207
Joined: 17-January 08
Member No.: 4,734



It there a way to stop JavaScript when tab is in the background? I have a local webpage. It is not on a server. I keep it in one of my tabs. Is there anyway to create a looping JavaScript that will pause when the page is in the background and resume when the page is active? For example, if I had a counter counting down seconds, can the script be stopped when not viewing the page to cut down the overhead?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 4 2021, 12:20 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



There's window.document.hasFocus() .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Ashly Rivera
post Jan 4 2022, 04:15 AM
Post #3





Group: Members
Posts: 1
Joined: 4-January 22
Member No.: 28,214



Did you have a fix on this issue? Facing same issue but no response from anyone and couldnt find this topic troubleshooting in google.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
denmarks
post Jan 4 2022, 09:41 AM
Post #4


Advanced Member
****

Group: Members
Posts: 207
Joined: 17-January 08
Member No.: 4,734



QUOTE(Ashly Rivera @ Jan 4 2022, 01:15 AM) *

Did you have a fix on this issue? Facing same issue but no response from anyone and couldnt find this topic troubleshooting in google.

The above post may work but I did not want to go through the trouble making the change. The code was only used for a page that is executed on my computer and not a website.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th March 2024 - 02:56 AM