<!DOCTYPE html PUBLIC "
<html>
<head>
<meta http
<title>浮動圖片</title>
<script type="text/javascript">
var step =
var y =
var x =
function myFloat()
{
var img = document
// 獲取圖片和當前浏覽器窗口上邊距
var top = img
// top = top
// img
// 獲取圖片和當前浏覽器窗口左邊距
var left = img
// left = left
// img
// 上下移動
if(top <=
{
y =
}
if(top >= document
{
y =
}
top = (top*
img
// 左右移動
if(left <=
{
x =
}
// alert(img
if(left >= (document
{
x =
}
left = (left*
img
setTimeout("myFloat()"
}
</script>
</head>
<body onload="myFloat();" style="height:
<img id="myImg" src="
style="position: absolute; left:
</body>
</html>
另一種的實現方式
<html>
<head>
<meta http
<title>浮動廣告實例</title>
<script type="text/javascript">
var pos =
function toueme() {
document
}
function initArray() {
this
for (var i =
this[i] = initArray
}
}
var col = new initArray("
col[
col[
col[
col[
col[
col[
col[
col[
col[
col[
function chgCol() {
pos++;
if (pos <
pos =
}
document
setTimeout("chgCol()"
}
</script>
</head>
<body bgColor="#ffffff" onload="chgCol();pingpong();">
<DIV id=img
style="Z
LEFT:
WIDTH:
POSITION: absolute;
TOP:
HEIGHT:
visibility: visible;">
<div id=toubiao>
<a style="CURSOR: hand" onClick=toueme()>
<img
src="close
width=
</div>
<a href="#" target="_blank">
<img src="
</a>
</DIV>
<SCRIPT>
var xPos =
var yPos =
var step =
var delay =
var height =
var Hoffset =
var Woffset =
var yon =
var xon =
var pause = true;
var interval;
img
function changePos()
{
width = document
height = document
Hoffset = img
Woffset = img
img
img
if (yon)
{yPos = yPos + step;}
else
{yPos = yPos
if (yPos <
{yon =
if (yPos >= (height
{yon =
if (xon)
{xPos = xPos + step;}
else
{xPos = xPos
if (xPos <
{xon =
if (xPos >= (width
{xon =
}
function start()
{
img
interval = setInterval(
//interval = setTimeout("changePos()"
}
function pause_resume()
{
if(pause)
{
clearInterval(interval);
pause = false;}
else
{
interval = setInterval(
pause = true;
}
}
start();
</SCRIPT>
</body>
</html>
JS實現氣泡從水中急速上升效果
<html>
<head>
<title>JS實現氣泡從水中急速上升效果</title>
<style type="text/css">
body {cursor:crosshair;margin:
</style>
<script type="text/javascript">
var object = new Array();
nbfm =
var xm =
var ym =
var nx =
var ny =
function movbulb(){
with (this) {
if(ec <
if(Math
xx = (xm
yy = (ym
ec++;
}
}
xx *=
yy *=
x
y
if(y
y
x
ec =
}
obj
obj
}
}
function CObj(N
this
this
this
this
document
this
this
this
this
this
this
this
this
this
this
this
}
function resize(){
nx = document
ny = document
}
onresize = resize;
document
if (window
xm = document
ym = document
}
function run(){
for(i in object)object[i]
setTimeout(run
}
onload = function() {
PIC = document
resize();
for(nbf=
sf = PIC[nbf%PIC
object[nbf] = new CObj(nbf
}
run();
}
</script>
</head>
<body>
<div id="bubbles" style="visibility:hidden">
<img src="smile
<img src="biggrin
<img src="eek
<img src="rolleyes
</div>
</body>
</html>
浮動廣告
<html>
<head>
<meta http
<title>浮動廣告</title>
</head>
<body style="background
<div id="ad" style="position:absolute">
<a href=http://www
<img src="
<input type="button" value="關閉窗口" onclick="closeWindow()"/><!
</a>
</div>
<script type="text/javascript">
var x =
var xin = true
var step =
var delay =
var obj=document
function floatAD()
{
var L=T=
var R= document
var B = document
obj
obj
x = x + step*(xin?
if (x < L) { xin = true; x = L}
if (x > R){ xin = false; x = R}
y = y + step*(yin?
if (y < T) { yin = true; y = T }
if (y > B) { yin = false; y = B }
}
var itl= setInterval("floatAD()"
function closeWindow()
{
window
}
</script>
<style type="text/css">
input{
background
border:
margin:
padding:
height:
width:
font
}
</style>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20253.html