HTML and CSS Reference
In-Depth Information
update is enough to demonstrate the concept. Let's see what happens
when the user visits the page.
1
The user starts on their home
page and decides to visit the
amazing Click Me application
they've heard about.
2
They type in the URL or fol-
low a link from an email to get
to the Click Me page.
3
After a few seconds of enjoy-
able interaction, the page state
has changed several times.
4
But when the user clicks the
Back button in the browser,
they find that instead of going
back to a previous page state,
they leap to their home page.
The
doclick()
function can be updated to take advantage of the history
API
. Each time the page is updated it will also set the
location.hash
:
function doclick() {
times++;
location.hash = times;
document.getElementById('message').innerHTML =
'Recorded <b>' + times + '</b> clicks';
}