thanks very much!!!please go on!!!

解决方案 »

  1.   

    稍微改了一下
    <html xmlns:v>
    <head>
    <meta http-equiv='Content-Type' content='text/html;charset=gb2312'>
    <title>&Icirc;&iuml;&frac14;&laquo;±&Oslash;·&acute;</title>
    <style>
    v\:*{behavior:url(#default#VML);}
    *{font-size:12px;color:;}
    a{text-decoration:none;}
    a:hover{color:red;}
    </style>
    <script>
    function Container(name, left, top, width, height) {
    this.name = name;
    this.left = left;
    this.top = top;
    this.width = width;
    this.height = height;
    this.obj = eval(name);
    this.put = function(obj) {
    obj.container = this;
    this.obj.insertAdjacentHTML("beforeEnd", obj.getCode())
    obj.obj = eval(obj.name);
    }
    this.checkLeft = function(x) {
    return (left<=x);
    }
    this.checkRight = function(x) {
    return (x<=left + width);
    }
    this.checkTop = function(y) {
    return (top<=y);
    }
    this.checkBottom = function(y) {
    return (y<=top + height);
    }
    }function SHAPE(name, shape, x, y, width, height, color, zindex, xa, ya) {
    this.name = name;
    this.shape = shape;
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;
    this.color = color;
    this.zindex = zindex;
    this.xa = xa;
    this.ya = ya;
    this.obj = null;
    this.container = null;

    this.move = function(xa, ya) {
    if (typeof(xa)!="undefined" && typeof(ya)!="undefined") {
    this.xa = xa;
    this.xa = ya;
    }
    with (this) {
    if (!container.checkLeft(x) || !container.checkRight(x + xa + width))
    xa = -xa;
    x += xa;

    if (!container.checkTop(y + ya) || !container.checkBottom(y + ya + height))
    ya = -ya;
    y += ya;

    obj.style.left = x;
    obj.style.top = y;
    }
    }
    this.getCode = function() {
    return "<v:" + shape + " fillcolor='" + this.color + "' style='position:absolute;left:" + this.x +";top:" + this.y + ";z-index:" + zindex + ";width:" + this.width + ";height:" + this.height + ";' id='" + this.name + "'/>";
    }
    }
    </script>
    </head>
    <body topmargin='2' leftmargin='2'>
    <div id=a style='table-Layout:fixed;width:100%;height:100%;border:1 solid black'></div>
    <script>
    var container = new Container("a", 0, 0, a.offsetWidth, a.offsetHeight);
    var obj = new Array();
    for (var i=0; i<5; i++) {
    shape = Math.round(Math.random())==1?"oval":"rect";
    size = Math.round(Math.random() * 70) + 20;
    x = Math.round(Math.random() * (a.offsetWidth - size));
    y = Math.round(Math.random() * (a.offsetHeight - size));
    color = "rgb(" + Math.round(Math.random()*255) + "," + Math.round(Math.random()*255) + "," + Math.round(Math.random()*255) + ")";
    xa = Math.round(Math.random()*10);
    ya = Math.round(Math.random()*10); obj[i] = new SHAPE("SHAPE" + i, shape, x, y, size, size, color, i, xa, ya);
    container.put(obj[i]);
    }
    function move() {
    for (i=0; i<obj.length; i++)
    obj[i].move();
    }
    setInterval("move();",10);
    </script>
    </body>
    </html>