HTML and CSS Reference
In-Depth Information
state = event.state;
document.getElementById('content').innerHTML = state.content;
} else {
history.replaceState(state, '', '#undo' + state.undonum);
}
}
E. HANDLE THE INITIAL STATE, AND ATTACH THE EVENT HANDLER
If there isn't a state object on the event, then this is the first load;
replace the current state with your initial state object. Now all that's
needed is to wire up the events:
window.onload = init;
window.onpopstate = popState;
window.onpageshow = popState;
Both onpopstate and onpageshow are required because Firefox, unlike
other browsers, doesn't fire popstate on the initial page load when no
state is set.
F. SET UP THE MENU BUTTONS
Finally, link the buttons on the menu to appropriate functions:
<button onclick="save();">Save</button>
<button onclick="history.go(-1);">Undo</button>
The HTML5 history API presents a powerful
tool for JavaScript—based applications and
has good cross—browser support. It's already
used on major websites such as Google Mail
and Twitter. In the next section, we'll look
at how you can use content that's been
semantically enhanced with microdata.
Standard
-
16
Getting semantic with the microdata API
The microdata API makes it convenient to
examine and update content that's been marked
up with microdata. Microdata was discussed in
chapter 1; it's a method of flexibly extending the
semantics of HTML to describe more than just
text content—for example, contact information,
-
12
-
 
Search WWH ::




Custom Search