The synchronization of localStorage between tabs is not working in Safari 14.1

Experience a scenario that functions in Safari 14.0, Chrome and Firefox, but not in Safari 14.1:

  1. Launch the demonstration in 2 different tabs
  2. Type some text and click on "Submit"
  3. Move to the other tab and click on "get"

You should be able to synchronize messages via localStorage between 2 tabs hosted on the same domain.

Demo code:

<h1>To localStorage</h1>
    <form id="form">
      <input id="text" type="text" />
      <input type="submit" />
    </form>

    <h1>From localStorage</h1>
    <button id="getout">get</button>
    <p id="out"></p>

    <script type="text/javascript">
      const form = document.getElementById("form");
      const text = document.getElementById("text");
      const out = document.getElementById("out");
      const getout = document.getElementById("getout");

      form.addEventListener("submit", function (e) {
        localStorage.setItem("test", text.value);
        e.preventDefault();
      });

      function retrieveContent() {
        out.textContent = localStorage.getItem("test");
      }
      retrieveContent();
      getout.addEventListener("click", retrieveContent);
      window.addEventListener("storage", retrieveContent);
    </script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to apply color to individual polygons based on a specific parameter using javascript?

I attempted to customize the colors of polygons loaded from a geojson file on Google Maps based on the "population density" data. However, my script failed to execute as intended. I tried to extract the "population density" information within a loop funct ...

Having trouble getting Tailwindcss to work with Next.js - what could be causing the configuration issue?

Why is tailwind not displaying correctly in my next.js project? I'm concerned that there might be a problem with my settings. In the styles folder, I have a file called tailwind.css @tailwind base; /* Write your own custom base styles here */ /* S ...

Why are users not visible in the Node.js application?

Good day! I am a newcomer to this community and I'm hoping to get some guidance in the right direction with my inquiries. Recently, I came across some code on Github that I am trying to improve upon. The code can be found at https://github.com/voroni ...

Tips for sending a JSON object to a node.js server

I recently created a test JSON object that looks like this { Id: 100, plugins: [{ Name: 'Test', Version: '2' }] } It was constructed using the following code snippet var json = {}; json.Id = 100; var plugins = []; json.plugins = pl ...

Guide on displaying a div upon clicking on a text box in asp.net with the help of jquery

I attempted it in this way: <script type="text/javascript"> $(document).ready(function () { $('#divID').hide(); $('#txtInsertComments').Onfocus(function () { $('#divID').show(); }); }); </script> //Asp.net ...

Prevent scaling in CSS3DRenderer

For a detailed explanation of what I am attempting to achieve, please refer to my previous question here. In summary: My goal is to have HTML elements rotate in sync with OrbitControls to give the illusion that these elements are attached to a globe and m ...

Improperly aligned rotation using tween.js and three.js

Utilizing three.js and tween.js, my goal is to develop a Rubik's cube made up of 27 small cubes grouped together for rotation by +Math.PI/2 or -Math.PI/2. To ensure smooth rotation, I am implementing the tween library. The specific issue I encounter ...

What sets Vue.js apart, class and staticClass - is there a distinction?

Can someone explain the distinction between class and staticClass in Vue.js render functions? While using Template Compilation, I noticed that the output varies based on what is provided to the HTML class attribute. For instance, when passing a single str ...

Navigate to Angular Link using Scope Data

I have the user's GPS location, which is not fixed. From the frontend, I need to open it as a Google Maps link. <a href="#" ng-click='window.open("https://www.google.com/maps/place/{{data.usergps}}", "_system", "location=yes"); return false;& ...

Move to the following <article>

I am currently working on developing a JavaScript function that will automatically scroll to the next article whenever the down arrow key is pressed. The challenge I am facing is that my HTML elements are all dynamic and are simply article tags without any ...

Refreshing a <div> element in Django, yet there is no visible update

As I utilize a barcode scanner to add objects to my array list, the data is populated after each scan depending on the scanning speed of the user. To exhibit this data, I have designed a dedicated page. My intention is to avoid refreshing the entire page b ...

Discovering the proper method to reach the parent element in jQuery while within the click event

How can I use jQuery to access the parent element within a click event? $(document).ready(function () { $(".lv1 li").click(function (event) { this.parentElement.parentElement.textContent = this.textContent; $.ajax({ type: 'post&apo ...

Fragment shader error occurs when multiple lights casting shadows are used in three.js

Imagine a scenario where you have a street with numerous streetlights (over 20) and you position an object nearby, expecting to see a shadow. The lights are represented as: var light = new THREE.PointLight(0xffffff, 0.5, 6.0); Only the street has .recei ...

Updating backgroundPosition for dual background images within an HTML element using Javascript

Issue at Hand: I am currently facing a challenge with two background images positioned on the body tag; one floating left and the other right. The image on the left has a padding of 50px on the left side, while the image on the right has a padding of 50px ...

Is it better to use regexp.test or string.replace first in my code?

When looking to replace certain parts of a string, is it better to use the replace method directly or first check if there is a match and then perform the replacement? var r1 = /"\+((:?[\w\.]+)(:?(:?\()(:?.*?)(:?\))|$){0,1})\ ...

`How to transfer data from the original array elements to their offspring`

I am faced with an array containing various names: [ { name: "John", lastName: "Doe", children: [ { name: "Max", lastName: "" }, { name: "Jay&quo ...

Attempting to fetch JSON information but encountering an error message stating "not a valid function."

I have been working on developing a programmer job board app and I am currently facing an issue with displaying JSON data on the main page. My goal is to eventually render the data, but for now, I just want to ensure that it appears in JSON format so that ...

Building a Div Tag Layout with CSS for Full Width and Left Position of 300px

Experiencing some trouble with styling a div element. My goal is to have the div start at left:300px and stretch across the entire width of the browser window. However, when I apply width:100%, the div extends beyond the boundaries of the browser screen. ...

jQuery Form: Despite the Ajax response being visible on the page, it does not appear in the source code

Utilizing Jquery Form for an Ajax image upload. This is the relevant HTML code: <div class="input_con imageupload_con"> <form action="processupload.php" method="post" enctype="multipart/form-data" id="MyUploadForm"> < ...

Is it possible to use jQuery to load an HTML file and extract its script?

I have a navigation bar with five buttons. Whenever a button is clicked, I want to dynamically load an HTML file using AJAX that includes some JavaScript code. The loaded file structure resembles the following: <div> content goes here... </div& ...