弹出可移动的编辑框

[size=large][color=darkred][b][size=small]/**
* 显示输入框内容并编辑
*/
[size=large][size=x-small]function editFieldVal(obj){
var isReadOnly = obj.isReadOnly;//控件是否可以编辑
var read = obj.className;
var text = obj.value;
var editDiv = document.getElementById("editDiv");
if(null!=editDiv)
return false;
var div= document.createElement("div");
div.style.position="relative";
div.style.left="400px";
div.style.width="400px";
div.style.height="300";
div.style.top="140px";
div.style.zIndex ="2000";
div.style.border="3px solid #b2ccb8";
div.style.backgroundColor="#e4ebe5";
div.setAttribute("id","editDiv");
var ta = document.createElement("textarea");
var text = text.replace(/。/g,'。'+'\r\n');
ta.value=text;
ta.style.margin="15px 15px 15px 15px";
ta.style.top="10px";
ta.style.paddingTop="5px";
ta.style.paddingLeft="5px";
ta.style.paddingRight="5px";
ta.style.fontSize="14";
ta.style.width="385px";
ta.style.height="260px";
div.appendChild(ta);
var save = document.createElement("button");
save.value="确定";
save.style.width="65px";
save.style.height="26px";
save.style.backgroundColor="#aec5e9";
save.style.marginLeft="37%";
save.style.marginTop="2%";
save.style.marginBottom="10px";
save.οnclick= function(){
var taval = ta.value.replace(/\r\n/g,'。');
taval = taval.replace(/[。]+/g,'。');
//特别约定这样处理
if(obj.name.indexOf("FixSpec.CSpecContent")!=-1){
tool.setAttrValue(dw['FixSpec'],"FixSpec.CSpecContent",taval);
sumFix();
}else{
obj.value = taval;
}
document.body.removeChild(div);
};
if(!isReadOnly){
save.disabled="disabled";
}
if(read=='read' || read == "readtextarea1"){
save.disabled="disabled";
ta.disabled="disabled";
}
div.appendChild(save);
rDrag.init(div);
var cancle = document.createElement("button");
cancle.value="取消";
cancle.style.width="65px";
cancle.style.height="26px";
cancle.style.backgroundColor="#aec5e9";
cancle.style.marginLeft="5%";
cancle.style.marginTop="2%";
cancle.style.marginBottom="10px";
cancle.οnclick= function(){
document.body.removeChild(div);
};
div.appendChild(cancle);
document.body.appendChild(div);
}[/size][/size]

[size=xx-large]/**
*悬浮框移动
*
*/
[size=large]var rDrag = {
o : null,
init : function(o) {
o.onmousedown = this.start;
},
start : function(e) {
var o;
e = rDrag.fixEvent(e);
e.preventDefault && e.preventDefault();
rDrag.o = o = this;
o.x = e.clientX - rDrag.o.offsetLeft;
o.y = e.clientY - rDrag.o.offsetTop;
document.onmousemove = rDrag.move;
document.onmouseup = rDrag.end;
},
move : function(e) {
e = rDrag.fixEvent(e);
var oLeft, oTop;
oLeft = e.clientX - rDrag.o.x;
oTop = e.clientY - rDrag.o.y;
rDrag.o.style.left = oLeft + 'px';
rDrag.o.style.top = oTop + 'px';
},
end : function(e) {
e = rDrag.fixEvent(e);
rDrag.o = document.onmousemove = document.onmouseup = null;
},
fixEvent : function(e) {
if (!e) {
e = window.event;
e.target = e.srcElement;
e.layerX = e.offsetX;
e.layerY = e.offsetY;
}
return e;
}
}[/b][/color][/size]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值