如何在每次尝试加载页面时添加加载 gif 图像,我有一个带有链接的管理页面,我希望在页面加载之前单击链接时它应该显示 gif 图像,我添加了一些标题标签和正文标签上的javascript代码我添加了这段代码
<div id="loading"></div>
管理页面看起来像这样
<html>
<head>
<script type="text/javascript">
function preloader(){
document.getElementById("loading").style.display = "none";
document.getElementById("content").style.display = "block";
}//preloader
window.onload = preloader;
</script>
<title>profile- Admin panel</title>
</head>
<body>
<div id="loading"></div>
<?php include 'includes/connect.php'; ?>
<?php include 'title_bar.php'; ?>
<link rel="stylesheet" href="css/loading.css">
<h3>admin panel system</h3>
<p> you are logged in as <b><?php echo $username?></b> [<?php echo $level_name;?>]</p>
<?php
if($user_level != 1){
header('location : profile.php');
}
?>
<p>
<ul class="dash">
<li>
<a href="#" title="Report" class="tip" data-placement="bottom" >
<img src="images/icons/report.png" alt="" />
<span>Report</span>
</a>
</li>
<li>
<a href="view.php" title="Customers" class="tip" data-placement="bottom" >
<img src="images/icons/customers.png" alt="" />
<span>Customers</span>
</a>
</li>
</ul>
</p>
<p>
<?php
if(isset($_GET['type']) && !empty($_GET['type'])){
?>
<table>
<tr><td width='150px'> Users</td><td>Options</td></tr>
<?php
$list_query = mysql_query("SELECT id, username, type FROM users");
while($run_list = mysql_fetch_array($list_query)){
$u_id = $run_list['id'];
$u_username = $run_list['username'];
$u_type = $run_list['type'];
?>
<tr><td><?php echo $u_username?></td><td>
<?php
if($u_type == 'a'){
echo "<a href='option.php?u_id=$u_id&type=$u_type'>Deactivate</a>";
} else{
echo "<a href='option.php?u_id=$u_id&type=$u_type'>activate</a>";
}
?>
</td></tr>
<?php
}
?>
</table>
<?php
} else{
echo "Select Options Above";
}
?>
</body>
</html>
这就是我在 loading.css 中的内容
div#content {
display: none;
}
div#loading {
top: 200 px;
margin: auto;
position: absolute;
z-index: 1000;
width: 160px;
height: 24px;
background: url('../images/loading (1).gif') no-repeat;
cursor: wait;
}