浮世惊华之邪皇谋妻:网页特效的问题

来源:百度文库 编辑:高校问答 时间:2024/03/28 17:11:32
我想找一种特效 是可以把一张图片来回动的

<div id="helpor_net" style="position:absolute; visibility:visible; left:0px; top:0px; z-index:-1">
<img src="http://code.helpor.net/picture/swimming.gif" border="0">
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
var _all = '';
var _style = '';
var wwidth, wheight;
var ydir = '++';
var xdir = '++';
var id1, id2, id3;
var x = 1;
var y = 1;
var x1, y1;
if(!isNS) {
_all='all.';
_style='.style';
}
function www_helpor_net() {
clearTimeout(id1);
clearTimeout(id2);
clearTimeout(id3);
if (isNS) {
wwidth = window.innerWidth - 55;
wheight = window.innerHeight - 50;
} else {
wwidth = document.body.clientWidth - 55;
wheight = document.body.clientHeight - 50;
}
id3 = setTimeout('randomdir()', 20000);
animate();
}
function randomdir() {
if (Math.floor(Math.random()*2)) {
(Math.floor(Math.random()*2)) ? xdir='--': xdir='++';
} else {
(Math.floor(Math.random()*2)) ? ydir='--': ydir='++';
}
id2 = setTimeout('randomdir()', 20000);
}
function animate() {
eval('x'+xdir);
eval('y'+ydir);
if (isNS) {
helpor_net.moveTo((x+pageXOffset),(y+pageYOffset))
} else {
helpor_net.pixelLeft = x+document.body.scrollLeft;
helpor_net.pixelTop = y+document.body.scrollTop;
}
if (isNS) {
if (helpor_net.top <= 5+pageYOffset) ydir = '++';
if (helpor_net.top >= wheight+pageYOffset) ydir = '--';
if (helpor_net.left >= wwidth+pageXOffset) xdir = '--';
if (helpor_net.left <= 5+pageXOffset) xdir = '++';
} else {
if (helpor_net.pixelTop <= 5+document.body.scrollTop) ydir = '++';
if (helpor_net.pixelTop >= wheight+document.body.scrollTop) ydir = '--';
if (helpor_net.pixelLeft >= wwidth+document.body.scrollLeft) xdir = '--';
if (helpor_net.pixelLeft <= 5+document.body.scrollLeft) xdir = '++';
}
id1 = setTimeout('animate()', 30);
}
var helpor_net=eval('document.'+_all+'helpor_net'+_style);
// -->
</script>

再把<body>改为:
<body OnLoad="www_helpor_net()" OnResize="www_helpor_net()">