俺是javascript新手,照着书本敲了个让链接按时消失的小程序,竟然也会出错,对了N遍书本也没找出哪里敲错,求高手解救,代码如下:<!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>无标题文档</title>
</head>
<body>
<script language="javascript" type="text/javascript">
var message='<b><a href="#" target="_blank">校园篮球赛火热招募中。</a></b>';
var backgroundcolor="#00ffff";
var displaymode=1;
var displayduration=5000;
var flashmode=1;
var flashtocolor="#ffff00";
function regenerate()
{
window.location.reload();
}
var which=0;
function flash()
{
if(which==0){
document.all;
topmsg.style.backgroundColor=flashtocolor;
which=1;
}
else
{
document.all
topmsg.style.backgroundColor=backgroundcolor;
which=0;
}
}
document.all
document.write('<span id="topmsg" style="position:absolute;visibility:hidden">'+message+'</span>');
function setmessage()
{
document.all.topmsg.style.left=document.body.scrollLeft+document.body.clientWidth/2-document.all.topmsg.offsetWidth/1;
document.all.topmsg.style.top=document.body.scrollTop+document.body.clientHeight-document.all.topmsg.offsetHeight-80;
document.all.topmsg.style.backgroundColor=backgroundcolor;
document.all.topmsg.style.visibility="visible";
if(displaymode==1)
{
setTimeout("topmsg.style.visbility='hidden'",displayduration);
}
else if (displaymode==2)
{
display(2);
}
if(flashmode==1)
{
setlnterval("flash()",1000);
}
}
document.all
window.onload=setmessage;
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<script language="javascript" type="text/javascript">
var message='<b><a href="#" target="_blank">校园篮球赛火热招募中。</a></b>';
var backgroundcolor="#00ffff";
var displaymode=1;
var displayduration=5000;
var flashmode=1;
var flashtocolor="#ffff00";
function regenerate()
{
window.location.reload();
}
var which=0;
function flash()
{
if(which==0){
document.all;
topmsg.style.backgroundColor=flashtocolor;
which=1;
}
else
{
document.all
topmsg.style.backgroundColor=backgroundcolor;
which=0;
}
}
document.all
document.write('<span id="topmsg" style="position:absolute;visibility:hidden">'+message+'</span>');
function setmessage()
{
document.all.topmsg.style.left=document.body.scrollLeft+document.body.clientWidth/2-document.all.topmsg.offsetWidth/1;
document.all.topmsg.style.top=document.body.scrollTop+document.body.clientHeight-document.all.topmsg.offsetHeight-80;
document.all.topmsg.style.backgroundColor=backgroundcolor;
document.all.topmsg.style.visibility="visible";
if(displaymode==1)
{
setTimeout("topmsg.style.visbility='hidden'",displayduration);
}
else if (displaymode==2)
{
display(2);
}
if(flashmode==1)
{
setlnterval("flash()",1000);
}
}
document.all
window.onload=setmessage;
</script>
</body>
</html>
下面这两句注释掉
document.all.topmsg.style.left=document.body.scrollLeft+document.body.clientWidth/2-document.all.topmsg.offsetWidth/1;
document.all.topmsg.style.top=document.body.scrollTop+document.body.clientHeight-document.all.topmsg.offsetHeight-80;就有效果了