Wicket 不为此提供解决方案。大多数 Wicket 应用程序使用全页重新提醒/重定向或 Ajax 来仅更新页面的一部分,而不是整个页面。我建议您尝试使用 CSS 关键帧。这个想法是在这两个 JS 事件上将 CSS 类添加到页面正文:beforeunload和DOMContentLoaded(又名domready)。当beforeunload被触发时,您需要删除fade-in并添加fade-outCSS 类。并对 执行相反的操作DOMContentLoaded。CSS 将如下所示:/* make keyframes that tell the start state and the end state of our object */ @-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } } @-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } } @keyframes fadeIn { from { opacity:0; } to { opacity:1; } } .fade-in { opacity:0; /* make things invisible upon start */ -webkit-animation:fadeIn ease-in 1; /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */ -moz-animation:fadeIn ease-in 1; animation:fadeIn ease-in 1; -webkit-animation-fill-mode:forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/ -moz-animation-fill-mode:forwards; animation-fill-mode:forwards; -webkit-animation-duration:1s; -moz-animation-duration:1s; animation-duration:1s; }我不太擅长 CSS,所以最好向 Google 询问更多信息。