From Documentation
Revision as of 07:48, 31 October 2017 by Rudyhuang (talk | contribs) (→‎Example)




The history pop state event used with onHistoryPopState to notify that user pressed BACK, FORWARD or others that causes the history changed (but still in the same desktop).

All root components of all pages of the desktop will receives this event.


Catch a HistoryPopStateEvent in a MVC controller

    <window id="win" apply="org.zkoss.MainController">
        <label id="lbl">Handle history states in MVC fashion.</label>
        <button id="btnHistoryAdd">Add History</button>
public class MainController extends SelectorComposer<Window> {
	private int position = 1;

	private Label lbl;

	public void addHistory() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("f1", position);
		map.put("f2", "Clicked: " + System.currentTimeMillis());
		getSelf().getDesktop().pushHistoryState(map, "", "?p" + position);

	@Listen("onHistoryPopState = #win")
	public void handleHistoryPopState(HistoryPopStateEvent event) {
		Map<String, ?> state = (Map<String, ?>) event.getState();
		if (state != null) {
  • Line 12: Desktop object provides pushHistoryState API to push history status.
  • Line 15: Listening on the onHistoryPopState event.
  • Line 17: Get history state object map.

Supported events

Event Type
None None

Supported Children


Use cases

Version Description Example Location

Version History

Version Date Content
8.5.0 Oct 2017 ZK-3711: Support HTML5 history API

Last Update : 2017/10/31

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.