How to detect a change in HTML5 Local Storage in the same window?

Sayuj Sehgal - Apr 17 '20 - - Dev Community

I want to detect if a local storage variable value is changed or not, But I have noticed that if I added an event listener on 'storage' event, I can detect the change only if I open the same link in ** another window** and then change the local storage value from that window, then it will show me the change in the first window. But I don't want this behavior I just wanted to observe the change in the same window. Is there any way to do it?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .