首先应知道二个函数,setTimeout()和setInterval()。
setTimeout(函数,延时时间),此函数只执行一次,若想执行多次,可通过一个循环实现。
setInterval(函数,交互时间),在载入后,每隔指定时间执行函数一次。
通过setInterval实现
<script language="javascript" type="text/javascript">
setInterval("show()", 300);
function show()
{
if(xx.style.visibility == "visible")
xx.style.visibility = "hidden";
else
xx.style.visibility = "visible";
}
</script>
<script language="javascript" type="text/javascript">
function showxx()
{
if(xx.style.visibility == "visible")
xx.style.visibility = "hidden";
else
xx.style.visibility = "visible";
setTimeout("showxx()", 300);
}
showxx();
</script>