日期:2014-05-16  浏览次数:20459 次

javascript 常用代码大全(超级收藏,强烈推荐)(2)

打开模式对话框
返回模式对话框的值
全屏幕打开 IE 窗口
脚本中中使用xml
一、验证类
1、数字验证内
2、时间类
3、表单类
4、字符类
5、浏览器类
6、结合类

二、功能类
1、时间与相关控件类
2、表单类
3、打印类
4、事件类
5、网页设计类
6、树型结构。
7、无边框效果的制作
8、连动下拉框技术
9、文本排序
10,画图类,含饼、柱、矢量贝滋曲线
11,操纵客户端注册表类
12,DIV层相关(拖拽、显示、隐藏、移动、增加)
13,TABLAE相关(客户端动态增加行列,模拟进度条,滚动列表等)
14,各种object classid=>相关类,如播放器,flash与脚本互动等
16, 刷新/模拟无刷新 异步调用类(XMLHttp或iframe,frame)


一个可以在页面上随意画线、多边形、圆,填充等功能的js? (part 2)


function mkOv2D(left, top, width, height) 
{ 
var s = this.stroke; 
width += s-1; 
height += s-1; 
var a = width>>1, b = height>>1, 
wod = width&1, hod = (height&1)+1, 
cx = left+a, cy = top+b, 
x = 0, y = b, 
aa = (a*a)<<1, bb = (b*b)<<1, 
st = (aa>>1)*(1-(b<<1)) + bb, 
tt = (bb>>1) - aa*((b<<1)-1); 

if (s-4 < 0 && (!(s-2) || width-51 > 0 && height-51 > 0)) 
{ 
var ox = 0, oy = b, 
w, h, 
pxl, pxr, pxt, pxb, pxw; 
while (y > 0) 
{ 
if (st < 0) 
{ 
st += bb*((x<<1)+3); 
tt += (bb<<1)*(++x); 
} 
else if (tt < 0) 
{ 
st += bb*((x<<1)+3) - (aa<<1)*(y-1); 
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3); 
w = x-ox; 
h = oy-y; 

if (w-1) 
{ 
pxw = w+1+(s&1); 
h = s; 
} 
else if (h-1) 
{ 
pxw = s; 
h += 1+(s&1); 
} 
else pxw = h = s; 
this.mkOvQds(cx, cy, -x+1, ox-pxw+w+wod, -oy, -h+oy+hod, pxw, h); 
ox = x; 
oy = y; 
} 
else 
{ 
tt -= aa*((y<<1)-3); 
st -= (aa<<1)*(--y); 
} 
} 
this.mkDiv(cx-a, cy-oy, s, (oy<<1)+hod); 
this.mkDiv(cx+a+wod-s+1, cy-oy, s, (oy<<1)+hod); 
} 

else 
{ 
var _a = (width-((s-1)<<1))>>1, 
_b = (height-((s-1)<<1))>>1, 
_x = 0, _y = _b, 
_aa = (_a*_a)<<1, _bb = (_b*_b)<<1, 
_st = (_aa>>1)*(1-(_b<<1)) + _bb, 
_tt = (_bb>>1) - _aa*((_b<<1)-1), 

pxl = new Array(), 
pxt = new Array(), 
_pxb = new Array(); 
pxl[0] = 0; 
pxt[0] = b; 
_pxb[0] = _b-1; 
while (y > 0) 
{ 
if (st < 0) 
{ 
st += bb*((x<<1)+3); 
tt += (bb<<1)*(++x); 
pxl[pxl.length] = x; 
pxt[pxt.length] = y; 
} 
else if (tt < 0) 
{ 
st += bb*((x<<1)+3) - (aa<<1)*(y-1); 
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3); 
pxl[pxl.length] = x; 
pxt[pxt.length] = y; 
} 
else 
{ 
tt -= aa*((y<<1)-3); 
st -= (aa<<1)*(--y); 
} 

if (_y > 0) 
{ 
if (_st < 0) 
{ 
_st += _bb*((_x<<1)+3); 
_tt += (_bb<<1)*(++_x); 
_pxb[_pxb.length] = _y-1; 
} 
else if (_tt < 0) 
{ 
_st += _bb*((_x<<1)+3) - (_aa<<1)*(_y-1); 
_tt += (_bb<<1)*(++_x) - _aa*(((_y--)<<1)-3); 
_pxb[_pxb.length] = _y-1; 
} 
else 
{ 
_tt -= _aa*((_y<<1)-3); 
_st -= (_aa<<1)*(--_y); 
_pxb[_pxb.length-1]--; 
} 
} 
} 

var ox = 0, oy = b, 
_oy = _pxb[0], 
l = pxl.length, 
w, h; 
for (var i = 0; i < l; i++) 
{ 
if (typeof _pxb[i] != "undefined") 
{ 
if (_pxb[i] < _oy || pxt[i] < oy) 
{ 
x = pxl[i]; 
this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, _oy+hod, x-ox, oy-_oy); 
ox = x; 
oy = pxt[i]; 
_oy = _pxb[i]; 
} 
} 
else 
{ 
x = pxl[i]; 
this.mkDiv(cx-x+1, cy-oy, 1, (oy<<1)+hod); 
this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod); 
ox = x; 
oy = pxt[i]; 
} 
} 
this.mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod); 
this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod); 
} 
} 


function mkOvDott(left, top, width, height) 
{ 
var a = width>>1, b = height>>1, 
wod = width&1, hod = height&1, 
cx = left+a, cy = top+b, 
x = 0, y = b, 
aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1, 
st = (aa2>>1)*(1-(b<<1)) + bb, 
tt = (bb>>1) - aa2*((b<<1)-1), 
drw = true; 
while (y > 0) 
{ 
if (st < 0) 
{ 
st += bb*((x<<1)+3); 
tt += (bb<<1)*(++x); 
} 
else if (tt < 0) 
{ 
st += bb*((x<<1)+3) - aa4*(y-1); 
tt += (bb<<1)*(++x) - aa2*(((y-