最简单的做法是在主体中放置一个带有以下CSS的div:
#hideAll
{
position: fixed;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
background-color: white;
z-index: 99; /* Higher than anything else in the document */
}
(注意位置:固定将不工作在IE6 – 我知道没有肯定火的方式在这个浏览器)
添加DIV像这样(直接在开始body标记之后):
直接显示DIV:
document.getElementById("hideAll").style.display = "block";
并隐藏它onload:
window.onload = function()
{ document.getElementById("hideAll").style.display = "none"; }
或使用jQuery
$(window).load(function() { document.getElementById("hideAll").style.display = "none"; });
这种方法的优点是它也适用于关闭JavaScript的客户端。它不应该导致任何闪烁或其他副作用,但没有测试它,我不能完全保证它的每个浏览器。