载入画面范例 [英] Loading screen example
问题描述
我的HTML:
<html>
<head>
<link rel="stylesheet" href="C:\Users\coeconsultant3\Desktop\Loadingexample\abccss.css">
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(window).load(function () {
$("#loader").fadeOut("slow");
})
</script>
</head>
<body>
<div id="loader"></div>
<div id="page1">
<p>
<h1>Hello World !!!
</h1>
</p>
</div>
</body>
</html>
用于加载程序的CSS:
#loader {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url('C:/Users/coeconsultant3/Desktop/Loadingexample/page-loader.gif') 50% 50% no-repeat rgb(249,249,249);
}
我使用了执行不同行为的脚本:
I have used script which does different behaviour:
当我使用div
id = loader
时,它直接显示了问候世界.
When I use div
id = loader
, it shows directly the hello world.
当我使用div
class = loader
时,它仅显示正在加载gif图像,而不会浏览该页面.
When I use div
class = loader
, it just shows loading gif image and does not go through the page.
我想知道这个程序的错误
I want to know the error for this program
推荐答案
您的代码运行正常.有关信息,最好使用$(document).ready()
.
Your code works perfectly fine. And for information $(document).ready()
is better to use.
链接CSS的方式,我假设您是直接打开HTML文件,即,双击文件(如果我输入错了,请更正我).如果是这种情况,那么您必须将jQuery链接更正为:
The way you've linked your CSS, I assume you're directly opening the HTML file, i.e. by double clicking on the file (correct me if I'm wrong). If this is the case then you've to correct your jQuery linking to:
<script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
这篇关于载入画面范例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!