Change the URL in the address bar without reloading the page
Let us say your URL had some clunky data like
http://yoursite.com/newurl.html. All you are doing is moving the old page to your history and updating the URL.
Continuously updating things while hovering over element
Let us say you want to update some data when the user moves their mouse over an element. The event you are interested in is
mousemove as in the following example.
This works quite well but you could do handle the events a little better by adding a small check in your mousemoveHandler function like the following:
To do some periodic updates, you need to use a timer. Let us say, you need to call a function every second. Following example does that:
This is perfect. But, you need to be careful that the periodicFunction won’t be called more than once. If that happens, there is nothing stopping from creating two timers or worse several. That’s why it is a good idea to save the timer information to a global variable. With this you can clear the timer if needed to stop the periodic update. And then, when needed again, you can start it.