<!doctype html>
<html>
<head>
<title>html5事件</title>
<meta charset=uft-8>
<script">
//省略部分代码
</script>
</head>
<body>
<a href="http://www.baidu.com" rel="external nofollow" >baidu</a>
<script>
(function(){
var showCount = 0;
EventUtil.addHandler(window, "load", function(event){
alert("Load 触发");
}); EventUtil.addHandler(window, "pageshow", function(event){
showCount++;
alert("pageshow 触发 " + showCount + " times");
}); }
)();
</script>
</body>
</html>
通过测试发现,FireFox 和 Safari5+ 均能将页面保存在内存中,IE,Chrome, Oprea 也可以触发pageshow事件,但没有将页面保存在内存中。
此外还要注意,指定了onunload 事件处理程序的页面会被自动排除在bfcache(浏览器特性)之外,即使处理程序是空的,原因在于,onunload 最常用于撤销 onload中所执行的
操作,而跳过 onload 后再次显示页面很可能会导致页面不正常。