Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
 <input type="text" name="data" value="" placeholder="change me" id="data" />
 <p id="fromEvent">Waiting for data via <code>storage</code> event...</p>
<script type="text/javascript">
window.addEventListener("storage", function (e) {
    if (e.key == 'storage-event-test') {
        // e.newValue ->  new value
        // localStorage['storage-event-test'] ->  old value in IE
        setTimeout(function(){
            var newValue = localStorage.getItem('storage-event-test'); // new value
             $('#fromEvent').html(newValue);
        }, 10); // delay
      }
  }, false);
  $('#data').live('keyup', function () {
     var changedValue = this.value;
      $('#fromEvent').html(changedValue);
       localStorage.setItem('storage-event-test', changedValue);
    });
</script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers