<!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> ? ?<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ? ?<title>自動(dòng)展開</title> ? ?<style type="text/css"> ? /*設(shè)置廣告和正文的CSS樣式*/ ? ? ?body{ ? ? ? ?padding:0px; ? ? ? ?margin:0 auto; ? ?} ? ?#art0{ ? ? ? ?margin:0 auto; ? ? ? ?text-align:center; ? ? ? ?height:300px; ? ? ? ?padding:10px; ? ? ? ?width:auto; ? ? ? ?background-color: yellow; ? ?} ? ?#artCont{ ? ? ? ?background:yellowgreen; ? ? ? ?height:30px; ? ? ? ?text-align:center; ? ? ? ?line-height:30px; ? ? ? ?width:800px; ? ? ? ?margin:0 auto; ? ?} ? ?</style> ? ?<script type="text/javascript"> ? ? ? ?//增加廣告寬度函數(shù) ? ? ? ?var w =0; ? ? ? ?function addW(){ ? ? ? ? ? ?if (w<800){ ? ? ? ? ? ? ? ?w +=10; ? ? ? ? ? ? ? ?document.getElementById("art0").width=w + "px"; ? ? ? ? ? ?} ? ? ? ? ? ?else{ ? ? ? ? ? ? ? ?return; ? ? ? ? ? ?} ? ? ? ? ? ?setTimeout("addW()",40); ? ? ? ?} ? ? ? ?function closeW(){ ? //減少?gòu)V告寬度函數(shù) ? ? ? ? ? ?if(w>0){ ? ? ? ? ? ? ? ?w-=10; ? ? ? ? ? ? ? ?document.getElementById("art0").width=w +"px"; ? ? ? ? ? ?} ? ? ? ? ? ?else{ ? ? ? ? ? ? ? ?document.getElementById("art0").style.display="none"; ? ? ? ? ? ? ? ?return; ? ? ? ? ? ?} ? ? ? ? ? ?setTimeout("closeW()",30); ? ? ? ?} ? ? ? ?document.onload = function (){ ? ? ? ? ? ?addW(); ? ? ? ? ? ?setTimeout("closeW()",5000); ? //在網(wǎng)頁加載完畢時(shí),調(diào)用增加寬度函數(shù),等待5秒鐘后調(diào)用減少寬度函數(shù)。 ? ? ? ?} ? ?</script></head><body><!--廣告和正文的HTML代碼--><div id="art0"> ? ?<h1>歡迎來到慕課網(wǎng)!</h1> ? ?<h3>大幅廣告</h3></div><div id="artCont"> ? ?慕課網(wǎng)歡迎你!</div></body></html>
我的代碼哪里出問題了?效果出不來
hudy
2016-03-28 21:06:34