UNPKG

history-events

Version:

Adds missing window.history events onpushstate, onreplacestate and onchangestate.

26 lines (21 loc) 678 B
<html> <head> <title>React App</title> <script src="index.js" type="text/javascript"></script> <script type="text/javascript"> var h = window.HistoryEvents; window.addEventListener('popstate', function(e) { console.log('changestate1 :: state:', e.state.timestamp); }); h.addEventListener(window, 'changestate', function(e) { console.log('changestate2 :: state:', e.state.timestamp); }); function goNext() { window.history.pushState({timestamp: Date.now()}, 'xxx'+Date.now(), 'xxx'+Date.now()); } </script> </head> <body> <button onclick="goNext()">GoNext</button> </body> </html>