javascript 控制显示隐藏如何实现
[解决办法]
大概改了下。里面还需要重写 。有些会有冲突的。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Introduction to the GNSS and LBS Association of China</title>
<script type="text/javascript" language="javascript">
var time = 500;
var h = 0;
function addCount()
{
if(time>0)
{
time--;
h = h+5;
}
else
{
return;
}
if(h>482) //高度
{
return;
}
document.getElementById("ads").style.display = "";
document.getElementById("ads").style.height = h+"px";
setTimeout("addCount()",30);
}
window.onload = function showAds()
{
addCount();
setTimeout("noneAds()",40000); //停留时间自己适当调整
}
</script>
<script type="text/javascript" language="javascript">
var T = 260;
var N = 260; //高度
function noneAds()
{
if(T>0)
{
T--;
N = N-5;
}
else
{
return;
}
if(N<0)
{
document.getElementById("ads").style.display = "none";
return;
}
document.getElementById("ads").style.height = N+"px";
setTimeout("noneAds()",30);
}
function goUp(){
if(document.getElementById("ads").style.display == "none"){
addCount();
time = 500;
h = 0;
}else{
noneAds();
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
body,td,th {
font-size: 12px;
color: #999999;
line-height:20px}
.STYLE1 {
font-size: 24px;
font-weight: bold;
color: #0066CC;
font-family: Arial, Helvetica, sans-serif;
}
.STYLE2 {
font-size: 18px;
font-weight: bold;
color: #333333;
}
.STYLE3 {
font-size: 24px;
color: #666666;
}
-->
</style></head>
<body>
<div id="ads" style="margin:auto; display:none; width:900px; top:0px; height:0px; border:solid 1px #000;
background-color:#fafafa; overflow:hidden; text-align:center;">
<td width="900" height="482"><a href="http://www.xiazai.com"><img src="1.gif" border="0" alt="javascript 控制显示隐藏怎么实现"></a></td>
</div>
<div id="bottom" style="margin:auto; width:900px; height:80px; border:solid 1px #000; background-color:#fafafa;
text-align:center;">
<div align="center"><br>
<span class="STYLE1">Introduction to the GNSS and LBS Association of China</span><br>
<span class="STYLE2"> </span><br>
<input type="button" value="remove A5 download" onclick="javascript:document.getElementById
('ads').remove();" />
<input type="button" value="remove bottom" onclick="javascript:document.getElementById('bottom').remove
();" />
<input type="button" value="return Up" onclick="javascript:goUp()" />
</div>
<p align="center" class="STYLE3"></p>
<p align="center" class="STYLE3"></p>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Introduction to the GNSS and LBS Association of China</title>
<script type="text/javascript" language="javascript">
var time = 500;
var h = 0;
function addCount()
{
if(time>0)
{
time--;
h = h+5;
}
else
{
return;
}
if(h>482) //高度
{
return;
}
document.getElementById("ads").style.display = "";
document.getElementById("ads").style.height = h+"px";
setTimeout("addCount()",30);
}
window.onload = function showAds()
{
addCount();
setTimeout("noneAds()",40000); //停留时间自己适当调整
}
</script>
<script type="text/javascript" language="javascript">
var T = 260;
var N = 260; //高度
function noneAds()
{
if(T>0)
{
T--;
N = N-5;
}
else
{
return;
}
if(N<0)
{
document.getElementById("ads").style.display = "none";
return;
}
document.getElementById("ads").style.height = N+"px";
setTimeout("noneAds()",30);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
body,td,th {
font-size: 12px;
color: #999999;
line-height:20px}
.STYLE1 {
font-size: 24px;
font-weight: bold;
color: #0066CC;
font-family: Arial, Helvetica, sans-serif;
}
.STYLE2 {
font-size: 18px;
font-weight: bold;
color: #333333;
}
.STYLE3 {
font-size: 24px;
color: #666666;
}
-->
</style></head>
<body>
<div id="ads" style="margin:auto; display:none; width:900px; top:0px; height:0px; border:solid 1px #000; background-color:#fafafa; overflow:hidden; text-align:center;">
<td width="900" height="482"><a href="http://www.xiazai.com"><img src="1.gif" border="0" alt="javascript 控制显示隐藏怎么实现"></a></td>
</div>
<div id="bottom" style="margin:auto; width:900px; height:80px; border:solid 1px #000; background-color:#fafafa; text-align:center;">
<div align="center"><br>
<span class="STYLE1">Introduction to the GNSS and LBS Association of China</span><br>
<span class="STYLE2"> </span><br>
<input type="button" value="hide A5 download" onclick="javascript:document.getElementById('ads').style.display='none';" />
<input type="button" value="show A5 download" onclick="javascript:document.getElementById('ads').style.display='block';" />
</div>
<p align="center" class="STYLE3"></p>
<p align="center" class="STYLE3"></p>
</div>
</body>
</html>