Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Javascript storage event not executed in WinForms custom web browser control

$
0
0

I have custom WinForm web browser control that works fine in most cases. The problem I'm having is connected with local storage events.

When adding a listener to the storage event (javascript):

window.addEventListener('storage', eventHandler,false)

the eventHandler function is never called. I have tried this with more than one window open (hosting the web browser control), but it does not work. If I open a regular browser (IE10) and my custom browser, it will only trigger the storage event in the regular web browser when I write to local storage in the custom web browser, not the other way around.

Listening to the storagecommit event works ok in the custom browser control:

window.addEventListener('storagecommit', eventHandler,false)

but that event is only triggerd in the browser that wrote to local storage.

Below is a sample web page I use to test local storage events:

<!DOCTYPE html>
<html>
  <head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Test</title>

<script>
 function eventHandler(e) {
   alert(e);
 };
 
 function writeToLocalStorage() {
window.localStorage.setItem('test', 'test');
 }
 
      window.addEventListener('storage', eventHandler, false)
    </script>
  </head>
  <body>
<p><button type="button" onclick="writeToLocalStorage();">Test</button></p>
  </body>
</html>

If anyone can provide some help it would be very appreciated.


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>