Unverified

Name

Browser Tab Message

About

This snippet replaces the text in the Browser Tab with one of your own whenever the browser tab is not in focus.

Language

Javascript

Rating

Voted: 1 by 1 user(s)

How to Setup Snippet

Paste code into Code Snippets as JS. Change the message to be displayed from "Don't Forget About Us" to whatever you want. Select the "Load JS in the <head> section" radio button and save the snippet. That's it - it's good to go!

Codevault

Bobby_Palmer

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Website/ Profile URL:

https://robert-palmer.co.uk

Snippet Source:

https://robert-palmer.co.uk/

History

Last modified:

14/04/2023

Important Note

This snippet has the following status:

Unverified

This snippet has not been verified, use with caution and at your own risk. See details provided by author in sidebar and click below to find out more.

Browser Tab Message

 
                    
1var pageTitle = document.title; // save original page title
2 var isPageActive = true; // variable to track page focus
3 
4 // function to change the page title and shake the text
5 function changeTitleAndShakeText() {
6 if (!isPageActive) { // check if page is not active
7 document.title = "❤️ Don't Forget About Us"; // change page title
8 setTimeout(function() {
9 document.title = pageTitle; // restore original page title after 1 second
10 }, 1000);
11 }
12 }
13 
14 // event listener to track page focus
15 window.addEventListener('focus', function() {
16 isPageActive = true; // page is active
17 document.title = pageTitle; // restore original page title
18 });
19 
20 window.addEventListener('blur', function() {
21 isPageActive = false; // page is not active
22 });
23 
24 // call changeTitleAndShakeText function every 5 seconds
25 setInterval(changeTitleAndShakeText, 5000);

1

Related Snippets

Please see some snippets below related to this snippet..

JavaScript

Unverified

0

Text fields makes autocomplete off

Added: 1 year ago

Last Updated: 1 year ago

Make text field autocomplete off using the Fluent forms plugin

JavaScript

Unverified

0

Reverse Order Repeater Field Jetengine

Added: 5 months ago

Last Updated: 5 months ago

Reverses the order of child elements corresponding to class 'jet-listing-dynamic-repeater__item'

JavaScript

Unverified

0

Hide elements where link is empty

Added: 1 year ago

Last Updated: 1 year ago

I usually use this in a template where the theme doesn't support hiding fields for example a social media icon where the link is not set for one network e.g. Facbook but it is set for another e.g. Lin...

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

JavaScript

Unverified

1

Browser Tab Message

Added: 1 year ago

Last Updated: 1 year ago

This snippet replaces the text in the Browser Tab with one of your own whenever the browser tab is not in focus.

JavaScript

Unverified

1

Change Browser Tab Title When Not in Focus

Added: 1 year ago

Last Updated: 1 year ago

Encourage visitors to return to your site by changing the title in the browser tab when it is not in focus. You can see it in action here... https://carpetzone.co.uk/

WordPress Admin

AI Verified

0

Hide "Screen Options" on the Admin Dashboard

Added: 1 year ago

Last Updated: 1 year ago

This snippet hides the "Screen Options" tab on the WordPress Admin Dashboard, except for yourself. This leaves you in sole control over what info panels appear on the Dashboard. With this snippet ac...