加载完成后,显示HTML页面

编程入门 行业动态 更新时间:2024-10-04 05:33:04
本文介绍了加载完成后,显示HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有办法强制浏览器只有在所有的页面的内容被完全加载显示一个页面(如图片,脚本,CSS等)?

Is there a way to force the browser to display a page only after all of the page's contents are completely loaded (such as images, scripts, css, etc)?

推荐答案

做的是把一个 DIV 在身体下面的CSS最简单的事情:

The easiest thing to do is putting a div with the following CSS in the body:

#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 - 我所知,没有在该浏览器这样做的安全可靠的方式)

(Note that position: fixed won't work in IE6 - I know of no sure-fire way of doing this in that browser)

添加DIV像这样(直接开通后体标记):

Add the DIV like so (directly after the opening body tag):

<div style="display: none" id="hideAll">&nbsp;</div>

显示DIV后直接:

show the DIV directly after :

<script type="text/javascript"> document.getElementById("hideAll").style.display = "block"; </script>

和隐藏的onload :

window.onload = function() { document.getElementById("hideAll").style.display = "none"; }

或使用jQuery

$(window).load(function() { document.getElementById("hideAll").style.display = "none"; });

这种方法的优点是,它也将为谁关闭了JavaScript客户端。它的不应的造成任何闪烁或其他副作用,但没有测试它,我不能完全保证它的每一个浏览器在那里。

this approach has the advantage that it will also work for clients who have JavaScript turned off. It shouldn't cause any flickering or other side-effects, but not having tested it, I can't entirely guarantee it for every browser out there.

更多推荐

加载完成后,显示HTML页面

本文发布于:2023-11-26 23:19:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635622.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   页面   完成后   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!