复代码代码如下:
<html>
<머리>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>크기 조정</title>
<스타일 유형="텍스트/css">
#rRightDown,#rLeftDown,#rLeftUp,#rRightUp,#rRight,#rLeft,#rUp,#rDown{
위치:절대;배경:#C00;너비:6px;높이:6px;z-색인:5;글꼴 크기:0;}
#rLeftDown,#rRightUp{cursor:ne-resize;}
#rRightDown,#rLeftUp{cursor:nw-resize;}
#r오른쪽,#r왼쪽{cursor:e-resize;}
#rUp,#rDown{cursor:n-resize;}
#rRightDown{ 하단:-3px; 오른쪽:-3px;}
#rLeftDown{ 하단:-3px; 왼쪽:-3px;}
#rRightUp{ top:-3px; 오른쪽:-3px;}
#rLeftUp{ top:-3px; 왼쪽:-3px;}
#r오른쪽{오른쪽:-3px; 상단:50%}
#r왼쪽{왼쪽:-3px; 상단:50%}
#rUp{ top:-3px; 왼쪽:50%}
#rDown{ 하단:-3px; 왼쪽:50%}
</style>
</head>
<본문>
<div id='ss' style="높이:100px; 너비:100px; 테두리:1px 솔리드 #000000; 위치:절대; 왼쪽:200px; 상단:200px;" >
<div id="rRightDown"> </div>
<div id="rLeftDown"> </div>
<div id="rRightUp"> </div>
<div id="rLeftUp"> </div>
<div id="rRight"> </div>
<div id="rLeft"> </div>
<div id="rUp"> </div>
<div id="rDown"></div>
</div>
<스크립트>
var Sys = (함수(ua){
var s = {};
s.IE = ua.match(/msie ([/d.]+)/)?true:false;
s.Firefox = ua.match(/firefox//([/d.]+)/)?true:false;
s.Chrome = ua.match(/chrome//([/d.]+)/)?true:false;
s.IE6 = (s.IE&&([/MSIE (/d)/.0/i.exec(navigator.userAgent)][0][1] == 6))?true:false;
s.IE7 = (s.IE&&([/MSIE (/d)/.0/i.exec(navigator.userAgent)][0][1] == 7))?true:false;
s.IE8 = (s.IE&&([/MSIE (/d)/.0/i.exec(navigator.userAgent)][0][1] == 8))?true:false;
반환 s;
})(navigator.userAgent.toLowerCase());
var $ = 함수(id) {
return document.getElementById(id);
};
var Css = 함수(e,o){
for(var i in o)
e.style[i] = o[i];
};
var Extend = function(대상, 소스) {
for(소스의 var 속성) {
목적지[속성] = 소스[속성];
}
};
var 바인딩 = 함수(객체, 재미) {
var args = Array.prototype.slice.call(arguments).slice(2);
반환 함수() {
return fun.apply(object, args);
}
};
var BindAsEventListener = function(객체, 재미) {
var args = Array.prototype.slice.call(arguments).slice(2);
반환 함수(이벤트) {
return fun.apply(object, [event || window.event].concat(args));
}
};
var CurrentStyle = 함수(요소){
return element.currentStyle || document.defaultView.getCompulatedStyle(요소, null);
};
함수 addListener(요소,e,fn){
element.addEventListener?element.addEventListener(e,fn,false):element.attachEvent("on" + e,fn);
};
함수 제거Listener(요소,e,fn){
element.removeEventListener?element.removeEventListener(e,fn,false):element.detachEvent("on" + e,fn)
};
var 클래스 = 함수(속성){
var _class = function(){return (arguments[0] !== null && this.initialize && typeof(this.initialize) == 'function') ? this.initialize.apply(this, 인수) : this;};
_class.prototype = 속성;
_class를 반환합니다.
};
var 크기 조정 =새 클래스({
초기화 : 함수(obj){
this.obj = obj;
this.resizeelm = null;
this.fun = null; //记录触发什么事件的索引
this.original = []; //记录开始状态的数组
this.width = null;
this.높이 = null;
this.fR = BindAsEventListener(this,this.resize);
this.fS = 바인딩(this,this.stop);
},
set : 함수(elm,방향){
if(!elm)return;
this.resizeelm = 느릅나무;
addListener(this.resizeelm,'mousedown',BindAsEventListener(this, this.start, this[direction]));
이거 돌려줘;
},
시작 : 함수(e,fun){
this.fun = 재미;
this.original = [parseInt(CurrentStyle(this.obj).width),parseInt(CurrentStyle(this.obj).height),parseInt(CurrentStyle(this.obj).left),parseInt(CurrentStyle(this.obj). 맨 위)];
this.width = (this.original[2]||0) + this.original[0];
this.height = (this.original[3]||0) + this.original[1];
addListener(document,"mousemove",this.fR);
addListener(document,'mouseup',this.fS);
},
크기 조정 : 함수(e){
this.fun(e);
Sys.IE?(this.resizeelm.onlosecapture=function(){this.fS()}):(this.resizeelm.onblur=function(){this.fS()})
},
정지 : 함수(){
RemoveListener(document, "mousemove", this.fR);
RemoveListener(document, "mousemove", this.fS);
window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
},
위로 : 함수(e){
this.height>e.clientY?Css(this.obj,{top:e.clientY + "px",height:this.height-e.clientY + "px"}):this.turnDown(e);
},
아래로 : 함수(e){
e.clientY>this.original[3]?Css(this.obj,{top:this.original[3]+'px',height:e.clientY-this.original[3]+'px'}): this.turnUp(e);
},
왼쪽 : 함수(e){
e.clientX<this.width?Css(this.obj,{left:e.clientX +'px',width:this.width-e.clientX + "px"}):this.turnRight(e);
},
오른쪽 : 함수(e){
e.clientX>this.original[2]?Css(this.obj,{left:this.original[2]+'px',width:e.clientX-this.original[2]+"px"}): this.turnLeft(e) ;
},
leftUp:함수(e){
this.up(e);this.left(e);
},
leftDown:함수(e){
this.left(e);this.down(e);
},
rightUp:함수(e){
this.up(e);this.right(e);
},
rightDown:함수(e){
this.right(e);this.down(e);
},
턴다운 : 함수(e){
Css(this.obj,{top:this.height+'px',height:e.clientY - this.height + 'px'});
},
턴업 : 함수(e){
Css(this.obj,{top : e.clientY +'px',height : this.original[3] - e.clientY +'px'});
},
TurnRight : 함수(e){
Css(this.obj,{left:this.width+'px',width:e.clientX- this.width +'px'});
},
TurnLeft : 함수(e){
Css(this.obj,{left:e.clientX +'px',width:this.original[2]-e.clientX+'px'});
}
});
window.onload = 함수(){
새로운 Resize($('ss')).set($('rUp'),'up').set($('rDown'),'down').set($('rLeft'),'left' ).set($('r오른쪽'),'오른쪽').set($(' rLeftUp'),'leftUp').set($('rLeftDown'),'leftDown').set($('rRightDown'),'rightDown').set($('rRightUp'),'rightUp') ;
}
</script>
</body>
</html>