Keep the JS/jQuery code working in Safari when the tab is not active

Asked
Active3 hr before
Viewed126 times

7 Answers

working
90%

I have a JS/jQuery code as shown below in which in which I want to keep the JS/jQuery code working when the session tab is not active.,The following code perfectly fine in Google Chrome but it doesn't work in Safari.,iOS 5 pauses JavaScript when tab is not active, I think that will be another question. I am wondering if you know any reason why my code above is not working in safari. – flash Jul 25 '20 at 14:15

You can replace counter (it counts seconds) with calculating time difference.

let lastActivity = new Date();
let logoutAfter = 3600;
...
let delta = (new Date()).getTime() - lastActivity.getTime();
if (delta > logoutAfter) {
   ...
}
load more v
88%

Note: Similar tools are available in other browsers; the Sources tab in Chrome, Debugger in Safari (see Safari Web Development Tools), etc.,Note: The easiest solution is to declare the iteration variable with let instead of var—the value of i associated with the function is then unique to each iteration. Unfortunately this does not work correctly with IE11, which is why we haven't used this approach in the "good" for loop.,For example, try going into your browser's developer console and start typing,If this feature is supported in your browser, it will autocomplete.

npm install - g jshint
load more v
72%

You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first-class API and should be your first consideration when using a plugin.,We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.,Readjusts the modal's positioning to counter a scrollbar in case one should appear, which would make the modal jump to the left.,Bring Bootstrap's components to life with over a dozen custom jQuery plugins. Easily include them all, or one by one.

$(document).off('.data-api')
load more v
65%

Note: Tab Groups and Theme Colors are not available in this release on macOS Big Sur.,Added discrete animation support for grid-template-columns and grid-template-rows (r278173),Added support for CSS Grid grid-template-columns repeat(auto-fill, …) and repeat(auto-fit, …),Added discrete animation support for border-image-repeat (r276465)

Domain-bound codes. On macOS Big Sur, added support to Security Code AutoFill for domain-bound, one-time codes sent over SMS; in the following 2FA SMS, Safari only offers to fill the code on example.com, and no other domain.

Your Example code is 123446.

@example.com #123446
75%

Get JavaScript & jQuery: The Missing Manual, 3rd Edition now with O’Reilly online learning.,To get your feet wet and provide a gentle introduction to JavaScript, your first program will be very simple:,Next, you’ll add your own JavaScript programming to this page.,While <script> tags usually appear in a web page’s <head>, you can put them and JavaScript programs directly in the page’s body.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/
html4/strict.dtd">
<html>

<head>
   <title>My Web Page</title>
   <script type="text/javascript">
   </script>
</head>
<!doctype html>
<html>

<head>
   <meta charset="UTF-8">
   <title>My Web Page</title>
   <script>
   </script>
</head>
<!doctype html>
<html>

<head>
   <meta charset="UTF-8">
   <title>My Web Page</title>
   <script>
      alert('hello world!');
   </script>
</head>
<!doctype html>
<html>

<head>
   <meta charset="UTF-8">
   <title>My Web Page</title>
   <script src="navigation.js"></script>
</head>
<script src="navigation.js"></script>
<script>
   alert('Hello world!');
</script>
<!doctype html>
<html>

<head>
   <meta charset="UTF-8">
   <title>My Web Page</title>
   <script src="navigation.js"></script>
   <script src="slideshow.js"></script>
   <script>
      alert('hello world!');
   </script>
</head>
load more v
40%

Some browsers may not decide to show any confirmation boxes unless the user has interacted with the page. This is used to prevent unwanted or malicious websites from creating unnecessary pop-ups. The user may have to interact with the page to see the confirmation message.,A tab or window closing in a browser can be detected by using the beforeunload event. This can be used to alert the user in case some data is unsaved on the page, or the user has mistakenly navigated away from the current page by closing the tab or the browser.,This method works for detecting both when a tab is being closed or when the browser is being closed.,How to detect the user browser ( Safari, Chrome, IE, Firefox and Opera ) using JavaScript ?

Syntax:

window.addEventListener('beforeunload', function(e) {
   e.preventDefault();
   e.returnValue = '';
});
load more v
22%

jQuery Learning Center,jQuery Core API Documentation,Browse or Submit jQuery Bugs

$("button.continue").html("Next Step...")
load more v

Other "working-undefined" queries related to "Keep the JS/jQuery code working in Safari when the tab is not active"