<!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">如果把上面的声明去掉,代码就正常运行,如果不去掉代码就出错了。这是为什么呢?下面是 js代码<script type="text/javascript">
document.write('<div id="img" style="position: absolute; left: 311; top: 815">');
document.write('<a href="http://www.cnkuai.cn" target="_blank"><img border="0" src="http://www.cnww.net/gg/img/80X80.gif"></a>');
document.write('</div>');
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 30;                     
var height = 0;                     
var Hoffset = 0;                    
var Woffset = 0;                     
var yon = 0;                    
var xon = 0;                     
var pause = true;                    
var interval;                    
img.style.top = yPos;                    
function changePos() {                   
width = document.body.clientWidth;                    
height = document.body.clientHeight;                    
Hoffset = img.offsetHeight;                    
Woffset = img.offsetWidth;                   
img.style.left = xPos + document.body.scrollLeft;                    
img.style.top = yPos + document.body.scrollTop;                    
if (yon) {                  
yPos = yPos + step;                    
}               
else {             
yPos = yPos - step;                    
}            
if (yPos < 0) {                  
yon = 1;                    
yPos = 0;                    
}                  
if (yPos >= (height - Hoffset)) {                    
yon = 0;                    
yPos = (height - Hoffset);                     
}                  
if (xon) {                    
xPos = xPos + step;                    
}                 
else {                 
xPos = xPos - step;                   
}                  
if (xPos < 0) {                    
xon = 1;                   
xPos = 0;                   
}         
if (xPos >= (width - Woffset)) {                    
xon = 0;           
xPos = (width - Woffset);                    
}                    
}                   
function start() {                    
img.visibility = "visible";                  
interval = setInterval('changePos()', delay);                    
}              
start();  
</script>