jsp 表拉伸
来源:互联网 发布:淘宝运营每天工作内容 编辑:程序博客网 时间:2024/05/22 06:27
window.addEvent('domready', setScrolTable);
var globalValue = 0;
function setScrolTable(){
var dataTable = $("dragColTable");
if(dataTable == null){
return ;
}
if(globalValue>0){
return;
}
globalValue++;
var ieVersion = getIEVersion();
var row = dataTable.rows[0];
if(row!=null){
for(var i=0; i<row.cells.length;i++){
var cellObj = row.cells[i];
var temp = cellObj.innerHTML;
cellObj.innerHTML = "";
var spanElement = document.createElement('<div id=myCreateSpan class=resizeDivClass onmousedown=MouseDownToResize(this) onmousemove=MouseMoveToResize(this) onmouseup=MouseUpToResize(this)></div>');
var imgElement = document.createElement('<img src="./images/common/box1.gif" width=3 height=20 style="display:block;" border="0"/>');
spanElement.appendChild(imgElement);
cellObj.appendChild(spanElement);
cellObj.innerHTML = cellObj.innerHTML + temp;
}
}
}
function MouseDownToResize(obj){
setTableLayoutToFixed();
obj.mouseDownX=event.clientX;
obj.pareneTdW=obj.parentElement.offsetWidth;
obj.pareneTableW=dragColTable.offsetWidth;
obj.setCapture();
}
function MouseMoveToResize(obj){
if(!obj.mouseDownX) return false;
var newWidth=obj.pareneTdW*1+event.clientX*1-obj.mouseDownX;
if(newWidth>0)
{
obj.parentElement.style.width = newWidth;
dragColTable.style.width=obj.pareneTableW*1+event.clientX*1-obj.mouseDownX;
}
}
function MouseUpToResize(obj){
obj.releaseCapture();
obj.mouseDownX=0;
}
function setTableLayoutToFixed()
{
if(dragColTable.style.tableLayout=='fixed')
return;
var headerTr=dragColTable.rows[0];
for(var i=0;i<headerTr.cells.length;i++)
{
headerTr.cells[i].styleOffsetWidth=headerTr.cells[i].offsetWidth;
}
for(var i=0;i<headerTr.cells.length;i++)
{
headerTr.cells[i].style.width=headerTr.cells[i].styleOffsetWidth;
}
dragColTable.style.tableLayout='fixed';
}
var theobject = null; //This gets a value as soon as a resize start
function resizeObject() {
this.el = null; //pointer to the object
this.dir = ""; //type of current resize (n, s, e, w, ne, nw, se, sw)
this.grabx = null; //Some useful values
this.graby = null;
this.width = null;
this.height = null;
this.left = null;
this.top = null;
}
//Find out what kind of resize! Return a string inlcluding the directions
function getDirection(el) {
var xPos, yPos, offset, dir;
dir = "";
offset = 8;
xPos = window.event.offsetX;
yPos = window.event.offsetY;
//The distance from the edge in pixels
var elm=window.event.srcElement
if(el.className=="dt_div"&&elm.className=="rollflag")
{
dir += "s";
}
return dir;
}
function doDown() {
var el = getReal(event.srcElement, "className", "dt_div");
if (el == null) {
theobject = null;
return;
}
dir = getDirection(el);
if (dir == "") return;
theobject = new resizeObject();
theobject.el = el;
theobject.dir = dir;
theobject.grabx = window.event.clientX;
theobject.graby = window.event.clientY;
theobject.width = el.offsetWidth;
theobject.height = el.offsetHeight;
theobject.left = el.offsetLeft;
theobject.top = el.offsetTop;
window.event.returnValue = false;
window.event.cancelBubble = true;
}
function doUp() {
if (theobject != null) {
theobject = null;
}
}
function doMove() {
var el, xPos, yPos, str, xMin, yMin;
xMin = 8; //The smallest width possible
yMin = 8; // height
el = getReal(event.srcElement, "className", "dt_div");
var elm=window.event.srcElement
if (el.className == "dt_div"&&elm.className=="rollflag") {
str = getDirection(el);
//Fix the cursor
if (str == "") str = "default";
else
str += "-resize";
elm.style.cursor = str;
}
//Dragging starts here
if(theobject != null) {
if (dir.indexOf("s") != -1)
theobject.el.style.height = Math.max(yMin, theobject.height + window.event.clientY - theobject.graby) + "px";
if (dir.indexOf("n") != -1) {
theobject.el.style.top = Math.min(theobject.top + window.event.clientY - theobject.graby, theobject.top + theobject.height - yMin) + "px";
theobject.el.style.height = Math.max(yMin, theobject.height - window.event.clientY + theobject.graby) + "px";
}
window.event.returnValue = false;
window.event.cancelBubble = true;
}
}
function getReal(el, type, value) {
//temp = el;
//while ((temp != null) && (temp.tagName != "BODY")) {
// if (eval("temp." + type) == value) {
// el = temp;
// return el;
// }
// temp = temp.parentElement;
//}
var ieVersion = getIEVersion();
if(ieVersion != "6"){
temp=document.getElementById("displayTableDiv");
if(temp!=null)
el=temp;
}
return el;
}
document.onmousedown = doDown;
document.onmouseup = doUp;
document.onmousemove = doMove;
function getIEVersion(){
var ua = navigator.userAgent;
var s = "MSIE";
if ((i = ua.indexOf(s)) >= 0) {
var version = parseFloat(ua.substr(i + s.length));
return version;
}else{
return "other";
}
}
0 0
- jsp 表拉伸
- 拉伸
- 给jsp或者html设置背景图片,并拉伸,铺满屏幕
- 基于查找表的灰度拉伸
- 查找表,对比对拉伸,直方图均衡
- OpenCV之查找表与直方图拉伸
- 计算直方图,利用查找表拉伸直方图,直方图均衡
- div拉伸
- 拉伸UIImage
- 图片拉伸
- 形状拉伸
- 图片拉伸
- image 拉伸
- image 拉伸
- 拉伸图片
- 背景图片拉伸
- 图片拉伸
- 图片拉伸
- 避免头文件的重定义
- jQuery ajax() 方法
- 基于log4cpp和boost的日志模块
- poj 2778 DNA Sequence AC自动机+矩阵快速幂
- oracle查看该用户的所有表名字、表注释、字段名、字段注释、是否为空、字段类型
- jsp 表拉伸
- 入行三年了,到明天是.
- toms官方網 xuhd fbg gTHmT
- (转)学习&使用技术的四种层次
- 使用STL解决八皇后问题
- 【HDU】4507 吉哥系列故事——恨7不成妻 数位DP
- Oracle 11gR2的ASM ADVM DRIVER STATUS显示 uninstalled
- chmod u+s用法和setuid(),seteuid()
- LV包包 TiKm FCi gdXFT