Javascript 在锁定选项卡之前,不会在iphone浏览器(chrome和safari)上触发存储事件

Javascript 在锁定选项卡之前,不会在iphone浏览器(chrome和safari)上触发存储事件,javascript,google-chrome,safari,local-storage,mobile-browser,Javascript,Google Chrome,Safari,Local Storage,Mobile Browser,使用ReactJS。创建两个组件来解释问题 Sample code: chrome browser window 1: https://localhost:5000/home componentDidMount(){ function callme(){ if (event.key == "1000") { console.log("triggerred from another window"); } } window.addEventListener("stor

使用ReactJS。创建两个组件来解释问题

Sample code:

chrome browser window 1: https://localhost:5000/home

componentDidMount(){
 function callme(){
  if (event.key == "1000") {
     console.log("triggerred from another window");
   }
 }
 window.addEventListener("storage", callme, false);
}

chrome browser window 2: https://localhost:5000/pay

componentDidMount(){
  localStorage.setItem("1000","hello");
  localStorage.removeItem("1000");
}
问题陈述:

1) open chrome browser on iPhone and open first URL(https://localhost:5000/home)

2) open a new window and open second URL(https://localhost:5000/pay)

when the second URL componentDidMount() will update localStorage and storage event on the first window should trigger, which is working in all the browsers on desktop but on mobile browsers.

It only triggers if I focus the window 1 then only the storage event is triggering. Whereas I want the storage event to trigger without focusing the second window.
根据MSDN,每当本地存储(同一来源)发生更新时,都会触发存储事件

note: This problem will happen on mobile browsers only.