用Javascript做flash做的事..才完成的一个类.Auntion(2)


/*
*
语言扩展包

By Auntion

QQ:82874972

Blog:Auntion@blogbus.com

Email:Auntion@Gmail.com

版权没有,随便使用.

使用时请勿删除此部分注释.谢谢!

*
*/



var Class={create: function() {return function() {this.initialize.apply(this, arguments);}}};$id = function(i){return document.getElementById(i);};$name = function(i){return document.getElementsByName(i);};$class = function(className,baseId) {var fatherId = null;if(!baseId){fatherId = document;}else{var id = baseId;fatherId = $id(id);}var basic = fatherId.getElementsByTagName('*') || document.all;var child = null;var classNames = null;var aggregate = []; for (var i = 0; i < basic.length; i++) {child = basic[i];classNames = child.className.split(' ');for (var j = 0; j < classNames.length; j++) {if (classNames[j] == className) {aggregate.push(child);break;}}}return aggregate;};String.prototype.toInt = function(){return parseInt(this.replace(/[a-zA-Z]+/,''));};Number.prototype.isZero = function(){return (this < 0) ? 0 : this;};Function.prototype.bind = function(e) {var md = this;return function(){return md.apply(e,arguments);}};Object.prototype.attachEvent=function(method,func){if(!this[method]) this[method]=func;else this[method]=this[method].attach(func);};Function.prototype.attach=function(func){var f=this;return function(){f();func();}};


example.html

复制代码 代码如下:


<!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=gb2312" />
<title>example1</title>
<script src="Language.js" language="javascript"></script>
<script src="Action.js" language="javascript"></script>
<style type="text/css">

*,body{
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
}

#main {
    margin:50px;
    padding:0px 0px 20px 0px;
    border:solid 1px #cccccc
}

#button {
    color:#0099FF;
}

#button li{
    margin-right:10px;
    padding:5px 0 0 0;
    width:104px;
    height:22px;
    border: solid 1px #cccccc;
    background-color: #eeeeee;
    float:left;
    text-align:center;
}

#demo{
    margin-top:20px;
    background-color:#CCCCCC;
    color:#f5f5f5;
    float:inherit;
    /*border:solid 1px #aaaaaa;*/
}

</style>
</head>
<body>

    <table border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>
    <div id="button">
        <ul>
            <li id="a">恢复初始值</li>
            <li id="b">隐藏</li>
            <li id="c">宽 + 30</li>
            <li id="d">高 + 30</li>
            <li id="e">宽 - 30</li>
            <li id="f">高 - 30</li>
            <li id="i">宽600,高100</li>
        </ul>

    </div>
            </td>
          </tr>
</table>

    <table border="0" align="center" cellpadding="0" cellspacing="0">
      <tr><td align="center" valign="middle">
        <div id="demo" style="height:200px;width:200px;"></div>
  </td></tr></table>

<script language="javascript" type="text/javascript">
var element = $id("demo");

var width = element.offsetWidth;
var height= element.offsetHeight;

alert(width)

var step = 0.115

function now(){
    this.nowWidth = element.style.width.toInt();
    this.nowHeight= element.style.height.toInt();
}

    $id("a").onmousedown = function(){

        new ShowHide(element,width,height,0,step);

    }

    $id("b").onmousedown = function(){

        new ShowHide(element,0,0,0,step);

    }

    $id("c").onmousedown = function(){

        var test = new now();
        new ShowHide(element,test.nowWidth+30,null,0,step);

    }

    $id("d").onmousedown = function(){

        var test = new now();
        new ShowHide(element,null,test.nowHeight+30,0,step);

    }

    $id("e").onmousedown = function(){

        var test = new now();
        new ShowHide(element,test.nowWidth-30,null,0,step);

    }

    $id("f").onmousedown = function(){

        var test = new now();
        new ShowHide(element,null,test.nowHeight-30,0,step);

    }

    $id("i").onmousedown = function(){

        new ShowHide(element,600,100,0,step)

    }
</script>
</body>
</html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjdfpx.html