您可以使被单击的链接/元素(对于onclick事件)在地址栏中设置URL哈希。 (即http://server.name/page#URLhash)如果是链接,您只需调整HREF属性,否则您可能需要操作window.location。
这将设置当前状态。当页面重新加载时,检查URL哈希的值。有关如何访问它的详细信息,请参见http://developer.mozilla.org/en/DOM/window.location。如果URL哈希仍然在地址栏中,您将能够获取该值。
然后使用该值确定要激活哪个菜单。这样就可以通过这种方式恢复状态。
There are some differences between browsers. Do a search on "Ajax History", in which some people have used the URL hash to preserve the state after Ajax actions. Not the exact same problem you are trying to solve but similar. Check out RSH:
http://code.google.com/p/reallysimplehistory/
相同的思想将被使用。