web前端|js教程
写了几个类,希望对大家用。
web前端-js教程
1.日历
网站cms源码,本机文件放进ubuntu,网站爬虫用nodejs,php分组排序,seo的跳槽lzw
易语言防破解模块源码,vscode一直有光标,ubuntu 系统 复制,tomcat下应用架构,sqlite溢出攻击,网页设计字体大小样式,服务器如何禁止访问的ip,html5 日历滚动插件,前端框架与后端框架结合,谷歌爬虫协议,php下载文件到本地,seo引擎,线上部署springboot,下载类网站模板,网页直播实时聊天代码,做自我介绍的网页模板下载,织梦5.6后台加载,css3 页面缩放,crm客户关系管理系统下载 java,微擎小程序如何安装lzw
#oContainer { width: 193px; padding: 3px; background-color: menu; border-left: buttonhighlight 1px solid; border-top: buttonhighlight 1px solid; border-right: buttonshadow 1px solid; border-bottom: buttonshadow 2px solid;}.DateTable { font: 10pt; word-break: break-all;}.WeekTd, .BlankTd { font: 10pt; border: 1px solid menu;}.Today { font: 10pt; color: red; cursor: hand; position: relative; left: 1px; top: 1px; border-left: 1px solid dimgray; border-top: 1px solid dimgray; border-right: 1px solid white; border-bottom: 1px solid white;}.MonthTd { font: 10pt; font-family: webdings; cursor: hand; border: 1px solid menu; zmm: expression(onmouseenter = function() { style.color = ‘red’; }, onmouseout = function() { style.color = ”; });}.SelectTd { border: 1px solid menu;}.over { position: relative; cursor: hand; border-right: 1px solid buttonshadow; border-bottom: 1px solid buttonshadow; border-left: 1px solid buttonhighlight; border-top: 1px solid buttonhighlight;}.out { border-left: 1px solid buttonface; border-top: 1px solid buttonface; border-right: 1px solid buttonface; border-bottom: 1px solid buttonface;}.down { position: relative; left: 1px; top: 1px; border-left: 1px solid dimgray; border-top: 1px solid dimgray; border-right: 1px solid white; border-bottom: 1px solid white;}
var oDate = new Object();
棋盘网站源码,ubuntu下svn配置,tomcat6 跨域问题,新浪标题爬虫,php接口慢 的排查思路,亚洲seo优化lzw
function DateClass(_container) { this.author = ’-ZMM’; this.version = ‘Web Calendar 1.0’; this.container = _container; this.weekArr = [‘日’, ‘一’, ‘二’, ‘三’, ‘四’, ‘五’, ‘六’]; this.dateArr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
this.showTable = function(_year, _month) { this.container.innerHTML = this.getDateTable(_year, _month); }
this.getDateTable = function(_year, _month) { if (this.checkArgs(_year, _month)) { _year = parseInt(this.checkDate(_year, _month).split(‘-‘)[0]); _month = parseInt(this.checkDate(_year, _month).split(‘-‘)[1]); this.Thead = ‘
\n’; this.Table = this.Thead + this.Tbody + this.TFoot; return this.Table; } else { return ‘Arguments Error!’; } }
this.firstPos = function(_year, _month) {return new Date(_year, _month-1, 1).getDay();}
this.lastPos = function(_year, _month) {return new Date(_year, _month-1, this.dateArr[_month-1]).getDay();}
this.checkYear = function(_year) {return ((_year % 4 == 0) && (_year % 100 != 0)) || (_year % 400 == 0);}
this.today = function(_year, _month, _date) {return (new Date().getFullYear() == _year) && (new Date().getMonth() == _month-1) && (new Date().getDate() == _date);}
this.checkArgs = function(_year, _month) {if (_year2100) return false;if (_month13) return false;return (!isNaN(_year) && !isNaN(_month)); }
this.checkDate = function(_year, _month) {if (_month12) { _year ++; _month = 1;}return _year + ‘-‘ + _month;}
this.showDateStr = function(_year, _month, _date, _week) {window.alert(_year + ‘年’ + _month + ‘月’ + _date + ‘日 星期’ + _week); }}
window.onload = function() {oDate = new DateClass(self.oContainer);oDate.showTable(new Date().getFullYear(), new Date().getMonth()+1);}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]2.简单的下拉菜单
#oData { display: none;}#oPanel {width: 120px;font-size: 12px;border: 1px solid menu;padding: 2px;position: absolute;display: none;}span {font-size: 12px;cursor: hand;}
var oMenu = new Object();
function Menu(_data, _panel) { this.author = ’-ZMM’; this.version = ‘Menu 1.0’; this.data = _data; this.panel = _panel;
this.drawMenu = function(_number, _offsetX, _offsetY) { var nodeArr = this.data.childNodes; var _handle = window.event.srcElement; for (var i=0; i<nodeArr.length; i++) { if (nodeArr[i].id == (item_ + _number)) { with (this) { panel.innerHTML = nodeArr[i].innerHTML; panel.style.left = this.getPosition(_handle).left + _offsetX; panel.style.top = this.getPosition(_handle).top + _offsetY; return true; } } } return false; }; this.getPosition = function(_object) { var _top = _left = 0; var _root = document.body; while (_object != _root) {_top += _object.offsetTop;_left += _object.offsetLeft;_object = _object.offsetParent; } return { top: _top, left: _left }; }; this.showMenu = function(_number, _offsetX, _offsetY) { if (this.drawMenu(_number, _offsetX, _offsetY)) { this.panel.style.display = inline; } else { window.alert(arguments error!); } }; this.hideMenu = function() { this.panel.style.display = one; };}window.onload = function() { oMenu = new Menu(self.oData, self.oPanel); document.onclick = new Function(oMenu.hideMenu(););}
命令一
命令二
命令三
命令四
命令五
命令六
命令七
命令八
菜单一
菜单二
菜单三
菜单四
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]3. QQ菜单效果
#oContainer { width: 130px; height: 300px; border: 1px solid menu;}
var oTime, oTencent = new Object();
function Tencent(_container) { this.author = ’-ZMM’; this.version = ‘Tencent 1.0’; this.container = _container; this.box = (function(_object) { var _box = document.createElement(‘DIV’); _box.id = ‘TencentBox’; _box.style.width = _object.offsetWidth; _box.style.height = _object.offsetHeight; return _box; })(this.container); this.container.appendChild(this.box); this.toolRecord = new Object(); this.barCount = 0;
this.drawTencent = function(_barList, _barHeight, _barDelay, _barAmount) { var _bool = true; this.barList = []; this.toolList = []; this.barHeight = _barHeight; this.barDelay = _barDelay; this.barAmount = _barAmount; for (var i in _barList) this.barCount ++; this.toolHeight = parseInt(this.box.style.height) – this.barCount * this.barHeight; for (var i in _barList) { var _bar = document.createElement(‘BUTTON’); _bar.style.width = this.box.style.width; _bar.style.height = _barHeight; _bar.style.textAlign = ‘center’; _bar.value = i.toString(); _bar.hideFocus = true; _bar.attachEvent(‘onclick’, this.doClick); this.box.appendChild(_bar);
var _tool = document.createElement(‘DIV’); _tool.align = ‘center’; _tool.style.width = this.container.offsetWidth – 2; _tool.style.overflowY = ‘auto’; _tool.style.fontSize = ‘9pt’; _tool.style.height = (_bool) ? this.toolHeight : 1 ; _tool.style.display = (_bool) ? ‘inline’ : ‘none’ ; _tool.innerHTML = (function(_array) { var _html = new String(); var _bool = new Boolean(true); _bool = _bool & (typeof(_array[1]) == ‘object’);_bool = _bool & (typeof(_array[2]) == ‘object’);_bool = _bool & (typeof(_array[3]) == ‘object’); if (_bool) { _bool = _bool & (_array[1].length == _array[2].length); _bool = _bool & (_array[1].length == _array[3].length); _bool = _bool & (_array[2].length == _array[3].length); if (_bool) {for (var j=0; j<_array[0]; j++) {_html +=
‘;_html += ‘‘;_html += ‘‘; } } else { window.alert(‘arguments error!’); } } else { _bool = _bool & (typeof(_array[1]) == ‘string’); _bool = _bool & (typeof(_array[2]) == ‘string’); _bool = _bool & (typeof(_array[3]) == ‘string’);
if (!_bool) { _html += ‘
‘; _html += ‘‘; _html += ‘‘; } else { window.alert(‘arguments error!’); } } return _html; })(_barList[i]); this.box.appendChild(_tool);
this.barList[this.barList.length] = _bar; this.toolList[this.toolList.length] = _tool; if (_bool) { this.barCurrent = _bar; this.toolCurrent = _tool; _bool = false; } } }
this.doClick = function() { var _eventBar = window.event.srcElement; with (oTencent) { if (!oTime && (barCurrent != _eventBar)) { for (var i=0; i<barList.length; i++) { if (barList[i] == _eventBar) { barCurrent = barList[i]; toolRecord = toolCurrent; toolCurrent = toolList[i]; toolCurrent.style.display = inline; changeTool(); return true; } } } else { return false; } } } this.changeTool = function() { if (parseInt(this.toolCurrent.style.height) 0) ? (parseInt(height) – this.barAmount) : 1 ; } with (this.toolCurrent.style) { height = ((parseInt(height) + this.barAmount) < this.toolHeight) ? (parseInt(height) + this.barAmount) : this.toolHeight ; } oTime = window.setTimeout(oTencent.changeTool(), this.barDelay); } else { this.toolRecord.style.display = one;oTime = window.clearTimeout(oTime); } }}window.onload = function() { var _barList = new Object(); _barList[我的同学] = [3, [.cn/zmm/Sample.jpg, .cn/zmm/Sample.jpg, .cn/zmm/Sample.jpg], [1.htm, 2.htm, 3.htm], [华华, 南南, 振振]]; _barList[我的同事] = [4, [.cn/zmm/Sample.jpg, .cn/zmm/Sample.jpg, .cn/zmm/Sample.jpg, .cn/zmm/Sample.jpg], [4.htm, 5.htm, 6.htm, 7.htm], [妖妖, 星空网络, 蛋蛋, 冰雪]]; _barList[管理设置] = [2, [.cn/zmm/Sample.jpg, .cn/zmm/Sample.jpg], [8.htm, 9.htm], [修改密码, 个人资料]]; _barList[黑 名 单] = [1, .cn/zmm/Sample.jpg, 10.htm, 松松]; var _barHeight = 21; var _barDelay = 10, _barAmount = 50; oTencent = new Tencent(self.oContainer); oTencent.drawTencent(_barList, _barHeight, _barDelay, _barAmount);}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]4.对联效果
var oCouplet = new Object();
function Couplet(_top, _width, _height, _offset, _delay, _amount) { this.author = ’-ZMM’; this.version = ‘Couplet 1.0’; this.top = _top; this.width = _width; this.height = _height; this.offset = _offset; this.delay = _delay; this.amount = _amount;
this.drawCouplet = function(_content) { this.content = _content; var _client = document.body.clientWidth; var _css = new String(); _css += ‘top: ‘ + this.top + ‘px;’; _css += ‘width: ‘ + this.width + ‘px;’; _css += ‘height: ‘ + this.height + ‘px;’; _css += ‘position: absolute;’; _css += ‘font-size: 12px;’; _css += ‘border: 1px solid menu;’; _css += ‘overflow: auto;’ var _html = new String(); _html += ‘
‘; _html += this.content;_html += ‘‘; _html += ‘
‘; _html += this.content; _html += ‘‘; return _html; }
this.doScroll = function() { var _left = document.getElementById(‘oCouplet_left’); var _right = document.getElementById(‘oCouplet_right’); var _oTop = parseInt(_left.style.top); var _nTop = parseInt(document.body.scrollTop) + this.top; if (_oTop 0) { _left.style.top = _right.style.top = _oTop + 1 + ‘px’; var oTime = window.setTimeout(‘oCouplet.doScroll()’, this.delay); } else { window.clearTimeout(oTime); } } else { if ((_oTop – _nTop) > 0) { _left.style.top = _right.style.top = _oTop – 1 + ‘px’; var oTime = window.setTimeout(‘oCouplet.doScroll()’, this.delay); } else { window.clearTimeout(oTime);} } }}
window.onload = function() { var oTop = 50, oWidth = 120, oHeight = 250, oOffset = 20; var oDelay = 80, oAmount = 1; oCouplet = new Couplet(oTop, oWidth, oHeight, oOffset, oDelay, oAmount); with (document.body) {innerHTML += oCouplet.drawCouplet(self.oContent.innerHTML);onscroll = function() { oCouplet.doScroll();} } }
对联内容
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]5.图片轮换
var oInterval, oTime, oRotator = new Object();
function Rotator(_container, _width, _height, _array, _delay) { this.author = ’-ZMM’; this.version = ‘Rotator 1.0’; this.container = _container; this.width = _width; this.height = _height;
this.box = (function(_container, _width, _height) { var _box = document.createElement(‘DIV’); _box.id = ‘RotatorBox’; _box.align = ‘center’; _box.style.width = _width; _box.style.height = _height; _box.style.border = ‘1px solid menu’; _box.style.overflow = ‘hidden’; return _box; })(this.container, this.width, this.height); this.container.appendChild(this.box); this.sAmount = 0;
this.drawRotator = function(_array, _delay) { this.delay = _delay; var _bool = (_array.length == 3); _bool = _bool & (_array[0].length == _array[1].length); _bool = _bool & (_array[0].length == _array[2].length); _bool = _bool & (_array[1].length == _array[2].length); if (_bool) { this.itemArr = []; this.panel = (function(_width, _height, _array) { var _panel = document.createElement(‘DIV’); _panel.style.position = ‘absolute’; _panel.style.top = ‘0px’; _panel.style.left = ‘0px’; return _panel; })(this.width, this.height, _array); for (var i=0; i<_array[0].length; i++) { var _html = new String(); _html +=
‘; this.itemArr[this.itemArr.length] = _html; } this.box.appendChild(this.panel); this.setPanelContent(); } else { window.alert(‘arguments error!’); } }
this.setPanelContent = function() { this.panel.innerHTML = this.itemArr.join(”); }
this.doScroll = function() { with (oRotator) { if (sAmount < height) { sAmount ++; panel.style.pixelTop = parseInt(panel.style.pixelTop) – 1; oTime = window.setTimeout(oRotator.doScroll(), 10); } else { sAmount = 0; itemArr.push(itemArr.shift()); setPanelContent(); panel.style.pixelTop = parseInt(panel.style.pixelTop) + height; window.clearTimeout(oTime);} }}}window.onload = function() { var _width = 50, _height = 30, _delay = 3000;var _array = []; _array[_array.length] = [/, /, /, /, /]; _array[_array.length] = [/images/default/profile.jpg, /images/default/email.jpg, /images/default/pm.jpg, /images/default/edit.jpg, /images/default/quote.jpg]; _array[_array.length] = [无忧脚本, Web中文网, 开创互联, 网易, 新浪]; oRotator = new Rotator(self.oContainer, _width, _height); oRotator.drawRotator(_array, _delay); oInterval = window.setInterval(oRotator.doScroll(), _delay);}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]6.listView类
#oContainer { width: 600px; height: 500px; border: 1px solid menu; margin: 0px; padding: 0px; overflow: hidden;}a { color: black; text-decoration: none;}a:hover { color: red; text-decoration: underline;}
var oListView = new Object();
function listView(_container) { this.author = ’-ZMM’; this.version = ‘ListView 1.0’; this.container = _container; this.box = new Object(); this.headerWidth = 0; this.headerHeight = 20; this.itemWidth = 0; this.itemHeight = 0; this.rowsCount = 30; this.isResize = false; this.separate = new Object(); this.startPoint = 0; this.endPoint = 0; this.tempSeparate = new Object(); this.put_headerHeight = function(_height) { return _height; }; this.get_headerHeight = function() { return this.headerHeight; }; this.put_rowsCount = function(_count) { return _count; }; this.get_rowsCount = function() { return this.rowsCount; };}
listView.prototype = { boxInit : function() { this.container.innerHTML = new String(); this.box = (function(_object) { var _box = document.createElement(‘DIV’); with (_box) { id = ‘ListViewBox’; style.width = _object.offsetWidth; style.height = _object.offsetHeight; style.margin = ‘0px’; style.padding = ‘0px’; attachEvent(‘oncontextmenu’, new Function(‘return false;’)); } return _box; })(this.container); this.headerPanel = (function(_width, _height) { var _headerPanel = document.createElement(‘DIV’); with (_headerPanel) { style.width = _width; style.height = _height; } return _headerPanel; })(this.box.style.width, this.headerHeight); this.headerPanel.appendChild(this.textPanel = (function() { var _textPanel = document.createElement(‘NOBR’); _textPanel.attachEvent(‘onmousemove’, function() { with (oListView) { if (event.button == 1) { textPanel.style.cursor = ‘E-resize’; tempSeparate.style.left = event.clientX – getPosition(box).left; tempSeparate.style.display = ‘inline’; endPoint = event.clientX; isResize = true; } } });return _textPanel; })()); this.rowItemPanel = (function(_width, _height) { var _itemPanel = document.createElement(‘DIV’); with (_itemPanel) { style.width = _width; style.height = _height; style.overflow = ‘hidden’; } return _itemPanel; })(this.box.style.width, parseInt(this.box.style.height) – this.headerHeight); this.rowItemPanel.appendChild(this.dataPanel = (function() { var _dataPanel = document.createElement(‘NOBR’); with (_dataPanel) { style.cursor = ‘default’; attachEvent(‘onclick’, function() { document.selection.empty(); }); attachEvent(‘onselectstart’, function() { document.selection.empty(); }); } return _dataPanel; })()); this.dataPanel.appendChild(this.tempSeparate = (function(_height) { var _tempSeparate = document.createElement(‘SPAN’); with (_tempSeparate) { style.width = ‘1px’; style.height = _height; style.border = ‘0px’; style.backgroundColor = ‘black’; style.position = ‘absolute’; style.display = ‘none’; } return _tempSeparate; })(this.rowItemPanel.style.height)); this.box.appendChild(this.headerPanel); this.box.appendChild(this.rowItemPanel); this.container.appendChild(this.box); },
drawListView : function(_headers, _aligns) { this.boxInit(); this.drawHeader(_headers); this.drawRowItem(_headers, _aligns); document.attachEvent(‘onmouseup’, this.finishResize); },
drawHeader : function(_headers) { this.headers = []; this.headerWidth = Math.round((parseInt(this.headerPanel.style.width) – (_headers.length – 1) * 1) / _headers.length) + 1; for (var i = 0; i < _headers.length; i ++) { var _header = document.createElement(SPAN); with (_header) { style.width = this.headerWidth; style.height = this.headerHeight; style.overflow = hidden; style.backgroundColor = uttonface; style.borderLeft = 1px solid buttonhighlight; style.borderTop = 1px solid buttonhighlight; style.borderRight = 1px solid buttonshadow; style.borderBottom = 1px solid buttonshadow; style.textAlign = center; style.fontSize = 12px; style.fontFamily = Sans-Serif, Tahoma; style.paddingTop = 1px; innerText = _headers[i]; } this.textPanel.appendChild(_header); this.headers[this.headers.length] = _header; var _separate = this.getSeparate(true); this.textPanel.appendChild(_separate); this.headers[this.headers.length] = _separate; } var _last = document.createElement(SPAN); with (_last) { style.width = this.headerPanel.offsetWidth; style.height = this.headerHeight; style.overflow = hidden; style.backgroundColor = uttonface; style.borderLeft = 1px solid buttonhighlight; style.borderTop = 1px solid buttonhighlight; style.borderRight = 1px solid buttonshadow; style.borderBottom = 1px solid buttonshadow; style.textAlign = center; style.fontSize = 12px; style.fontFamily = Sans-Serif, Tahoma; style.paddingTop = 1px; innerText = new String(); } this.textPanel.appendChild(_last); this.headers[this.headers.length] = _last;},drawRowItem : function(_headers, _aligns) { this.items = []; this.itemWidth = Math.round((parseInt(this.rowItemPanel.style.width) – (_headers.length – 1) * 1) / _headers.length) + 1; this.itemHeight = parseInt(this.rowItemPanel.style.height) – 2; for (var i = 0; i < _headers.length; i ++) { var _item = document.createElement(SPAN); with (_item) { style.width = this.itemWidth; style.height = this.itemHeight; style.overflow = hidden; style.padding = px; appendChild((function(_count, _width, _height, _align) { var _table = document.createElement(TABLE); with (_table) { cellSpacing = 0; cellPadding = 0; style.width = _width; style.tableLayout = fixed; } var _tbody = document.createElement(TBODY); for (var i = 0; i < _count; i ++) { var _tableTr = document.createElement(TR); var _tableTd = document.createElement(TD); with (_tableTd) { align = _align; style.height = _height; style.borderBottom = 1px solid #c6c3c6; style.fontSize = 12px; style.paddingLeft = 3px; setAttribute(onclick, function() { oListView.selectedRow(this.parentNode.rowIndex); }); setAttribute(ondblclick, function() { oListView.showSelected(this.parentNode.rowIndex); }); innerHTML = new String( ); } _tableTr.appendChild(_tableTd); _tbody.appendChild(_tableTr); } _table.appendChild(_tbody); return _table; })(this.rowsCount, this.itemWidth, Math.round(this.itemHeight / this.rowsCount), _aligns[i])); } this.dataPanel.appendChild(_item); this.items[this.items.length] = _item; var _separate = this.getSeparate(false); _separate.style.height = this.itemHeight; this.dataPanel.appendChild(_separate); this.items[this.items.length] = _separate;} var _last = document.createElement(SPAN); with (_last) { style.width = this.rowItemPanel.offsetWidth; style.height = this.itemHeight; style.overflow = hidden; style.padding = px; appendChild((function(_count, _width, _height) { var _table = document.createElement(TABLE); with (_table) {cellSpacing = 0;cellPadding = 0;style.width = 100%; } var _tbody = document.createElement(TBODY); for (var i = 0; i < _count; i ++) { var _tableTr = document.createElement(TR); var _tableTd = document.createElement(TD); with (_tableTd) { style.height = _height;style.borderBottom = 1px solid menu; innerHTML = new String( ‘); } _tableTr.appendChild(_tableTd); _tbody.appendChild(_tableTr); } _table.appendChild(_tbody); return _table; })(this.rowsCount, this.itemWidth, Math.round(this.itemHeight / this.rowsCount))); } this.dataPanel.appendChild(_last); this.items[this.items.length] = _last;},
getSeparate : function(_resize) { var _separate = document.createElement(‘SPAN’); with (_separate) { style.width = _resize ? ‘2px’ : ‘1px’ ; style.height = this.headerHeight; style.border = ‘1px ‘ + (_resize ? ‘inset white’ : ‘solid #c6c3c6’); style.overflow = ‘hidden’; style.position = ‘absolute’; if (_resize) { attachEvent(‘onmousedown’, function() { with (oListView) { separate = event.srcElement; startPoint = event.clientX; } }); attachEvent(‘onmouseenter’, function() { event.srcElement.style.cursor = ‘E-resize’; }); } } return _separate;},
getPosition : function(_object) { var _top = _left = 0; var _root = document.body; while (_object != _root) { _left += _object.offsetLeft; _object = _object.offsetParent; } return { left: _left }; },
resizeItem : function() { with (this) { var _width, _movePart = endPoint – startPoint; for (var i = 0; i < headers.length; i ++) { if (headers[i] == separate) { var _bool = true; _bool = _bool && (_movePart < 0); _bool = _bool && (parseInt(headers[i – 1].style.width) < Math.abs(_movePart)); if (_bool) {headers[i – 1].style.width = 0;items[i – 1].style.width = 0; } else {_width = parseInt(headers[i – 1].style.width);headers[i – 1].style.width = _width + _movePart;_width = parseInt(items[i – 1].style.width);items[i – 1].style.width = _width + _movePart;_width = parseInt(items[i – 1].firstChild.style.width);items[i – 1].firstChild.style.width = _width + _movePart;var _table = items[i – 1].firstChild;for (var j = 0; j this.rowsCount ? this.rowsCount : _datas.length ; for (var i = 0; i < _itemNum; i ++) { var n = 0; for (j = 0; j < this.items.length – 2; j ++) { if (j % 2 == 0) { var _dataPanel = document.createElement(NOBR); var _tableCell = this.items[j].firstChild.rows[i].cells[0]; with (_dataPanel) { style.width = this.itemWidth; style.overflow = hidden; style.textOverflow = ellipsis; innerHTML = _datas[i][n]; } _tableCell.innerHTML = new String(); _tableCell.appendChild(_dataPanel); _tableCell.title = _datas[i][0]; n ++; } } } }, selectedRow : function(n) { for (var i = 0; i < this.items.length; i++) { if (i % 2 == 0) {var _table = this.items[i].firstChild;for (var j = 0; j < _table.rows.length; j ++) { var _dataPanel = _table.rows[j].cells[0].children[0]; if (typeof _dataPanel != undefined) {if (j == n) { _table.rows[j].cells[0].style.color = highlighttext; _table.rows[j].cells[0].style.backgroundColor = highlight;} else { _table.rows[j].cells[0].style.color = \; _table.rows[j].cells[0].style.backgroundColor = \;}var _children = _table.rows[j].cells[0].firstChild.children;this.changeChild(_children, j == n); }} } } }, changeChild : function(_children, _isSelected) { if (typeof _children != undefined) { for (var i = 0; i < _children.length; i ++) {if (_isSelected) {_children[i].style.color = highlighttext;_children[i].style.backgroundColor = highlight;} else {_children[i].style.color = \;_children[i].style.backgroundColor = \;} } } else { return false; } }, showSelected : function(n) { var _text = new String(); for (var i = 0; i < this.items.length – 2; i++) { if (i % 2 == 0) {var _table = this.items[i].firstChild;_text += this.headers[i].innerText + :\n;_text += _table.rows[n].cells[0].firstChild.innerHTML + \ \n; } } alert(_text); } } function initListView() { var _headers = []; _headers[_headers.length] = 标题; _headers[_headers.length] = 内容; _headers[_headers.length] = 时间; _headers[_headers.length] = 管理; var _aligns = []; _aligns[_aligns.length] = left; _aligns[_aligns.length] = left; _aligns[_aligns.length] = center; _aligns[_aligns.length] = center; oListView = new listView(self.oContainer); oListView.drawListView(_headers, _aligns); var _items = []; _items[_items.length] = [标题一, 内容一, -6-21 10:30:00, 编辑 删除]; _items[_items.length] = [标题二, 内容二, -6-21 14:20:12, 编辑 删除]; _items[_items.length] = [标题三, 内容三, -6-21 20:45:36, 编辑 删除]; oListView.addListItem(_items); }attachEvent(onload, initListView);
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]7.表单多文件上传类 [ASP]
2 Then
ReDim Preserve itemStart(itemCount)
ReDim Preserve itemLength(itemCount)
itemStart(itemCount) = iStart
itemLength(itemCount) = iLength
itemCount = itemCount + 1
End If
Loop
Call FillItemValue
End Function
Private Function FillItemValue
Dim dataPart, bInfor
Dim iStart : iStart = 1
Dim iCount : iCount = 0
Dim iCheck : iCheck = StrToByte(“filename”)
For i = 0 To itemCount – 1
ReDim Preserve itemName(iCount)
ReDim Preserve itemData(iCount)
ReDim Preserve extenArr(iCount)
ReDim Preserve dataStart(iCount)
ReDim Preserve dataLength(iCount)
dataPart = MidB(formData, itemStart(i), itemLength(i))
iStart = InStrB(1, dataPart, ChrB(34)) + 1
iLength = InStrB(iStart, dataPart, ChrB(34)) – iStart
itemName(iCount) = FormItemName(MidB(dataPart, iStart, iLength))
iStart = InStrB(1, dataPart, bVBCrlf) + 4
iLength = LenB(dataPart) – iStart + 1
If InStrB(1, dataPart, iCheck) > 0 Then
bInfor = MidB(dataPart, 1, iStart – 5)
extenArr(iCount) = FileExtenName(bInfor)
If Mid(folderPath, Len(folderPath) – 1) = “/” Then
itemData(iCount) = folderPath & GetRndName(6) & extenArr(iCount)
Else
itemData(iCount) = folderPath & “/” & GetRndName(6) & extenArr(iCount)
End If
dataStart(iCount) = itemStart(i) + iStart – 2
dataLength(iCount) = iLength
Else
extenArr(iCount) = “”
itemData(iCount) = ByteToStr(MidB(dataPart, iStart, iLength))
dataStart(iCount) = “”
dataLength(iCount) = “”
End If
iCount = iCount + 1
Next
Call SaveUpload
End Function
Private Function FormItemName(byVal bName)
FormItemName = ByteToStr(bName)
End Function
Private Function FileExtenName(byVal bInfor)
Dim pStart, pLength, pContent, regEx
pStart = InStr(1, ByteToStr(bInfor), “filename=” & Chr(34)) + 10
pLength = InStr(pStart, ByteToStr(bInfor), Chr(34)) – pStart
pContent = Mid(ByteToStr(bInfor), pStart, pLength)
If pContent = “” Then
FileExtenName = “”
Else
Set regEx = New RegExp
regEx.Pattern = “^.*(\.[^\.]*)$”
regEx.Global = False
regEx.IgnoreCase = True
FileExtenName = regEx.Replace(pContent, “$1”)
Set regEx = Nothing
End If
End Function
Private Function GetRndName(byVal sLen)
Dim regEx, sTemp, arrFields, n : n = 0
Set regEx = New RegExp
regEx.Pattern = “[^\d]*”
regEx.Global = True
regEx.IgnoreCase = True
sTemp = regEx.Replace(Now, “”) & “-“
Set regEx = Nothing
arrFields = Array(“0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, _
“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, _
“k”, “l”, “m”, “n”, “o”, “p”, “q”, “r”, “s”, “t”, _
“u”, “v”, “w”, “x”, “y”, “z”, “A”, “B”, “C”, “D”, _
“E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”, “N”, _
“O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, _
“Y”, “Z”)
Randomize
Do While n < sLensTemp = sTemp & CStr(arrFields(61 * Rnd))n = n + 1 Loop GetRndName = sTemp End Function Private Function SaveUpload Dim isValidate Dim filePath, oStreamGet, oStreamPut isValidate = CheckFile If isValidate ThenFor i = 0 To itemCount – 1 If (dataStart(i) “”) And (dataLength(i) “”) Then
If dataLength(i) = 0 Then
itemData(i) = “”
Else
filePath = Server.MapPath(itemData(i))
If CreateFolder(“|”, ParentFolder(filePath)) Then
Set oStreamGet = Server.CreateObject(“ADODB.Stream”)
oStreamGet.Type = 1
oStreamGet.Mode = 3
oStreamGet.Open
oStreamGet.Write formData
oStreamGet.Position = dataStart(i)
Set oStreamPut = Server.CreateObject(“ADODB.Stream”)
oStreamPut.Type = 1
oStreamPut.Mode = 3
oStreamPut.Open
oStreamPut.Write oStreamGet.Read(dataLength(i))
oStreamPut.SaveToFile(filePath)
oStreamGet.Close
Set oStreamGet = Nothing
oStreamPut.Close
Set oStreamPut = Nothing
End If
End If
End If
Next
Finished = True
Call ItemToColl
Else
Finished = False
End If
End Function
Private Function CheckFile
Dim oBoolean : oBoolean = True
If cFields = “” Then
oBoolean = oBoolean And True
Else
For i = 0 To itemCount – 1
If extenArr(i) “” Then
If InStr(1, Ucase(cFields), “|” & Ucase(Mid(extenArr(i), 2)) & “|”) > 0 Then
oBoolean = oBoolean And True
Else
sErrors = sErrors & “表单[ ” & itemName(i) & ” ]的文件格式错误!\n” & _
“支持的格式为:” & Replace(Mid(cFields, 2, Len(cFields) – 1), “|”, ” “) & “\n\n”
oBoolean = oBoolean And False
End If
End If
Next
End If
CheckFile = oBoolean
End Function
Private Function CreateFolder(byVal sLine, byVal sPath)
Dim oFso
Set oFso = Server.CreateObject(“Scripting.FileSystemObject”)
If Not oFso.FolderExists(sPath) Then
Dim regEx
Set regEx = New RegExp
regEx.Pattern = “^(.*)\\([^\\]*)$”
regEx.Global = False
regEx.IgnoreCase = True
sLine = sLine & regEx.Replace(sPath, “$2”) & “|”
sPath = regEx.Replace(sPath, “$1”)
If CreateFolder(sLine, sPath) Then CreateFolder = True
Set regEx = Nothing
Else
If sLine = “|” Then
CreateFolder = True
Else
Dim sTemp : sTemp = Mid(sLine, 2, Len(sLine) – 2)
If InStrRev(sTemp, “|”) = 0 Then
sLine = “|”
sPath = sPath & “\” & sTemp
Else
Dim Folder : Folder = Mid(sTemp, InStrRev(sTemp, “|”) + 1)
sLine = “|” & Mid(sTemp, 1, InStrRev(sTemp, “|”) – 1) & “|”
sPath = sPath & “\” & Folder
End If
oFso.CreateFolder sPath
If CreateFolder(sLine, sPath) Then CreateFolder = True
End if
End If
Set oFso = Nothing
End Function
Function ParentFolder(byVal sPath)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = “^(.*)\\[^\\]*$”
regEx.Global = True
regEx.IgnoreCase = True
ParentFolder = regEx.Replace(sPath, “$1”)
Set regEx = Nothing
End Function
Private Function StrToByte(byVal sText)
For i = 1 To Len(sText)
StrToByte = StrToByte & ChrB(Asc(Mid(sText, i, 1)))
Next
End Function
Private Function ByteToStr(byVal sByte)
Dim oStream
Set oStream = Server.CreateObject(“ADODB.Stream”)
oStream.Type = 2
oStream.Mode = 3
oStream.Open
oStream.WriteText sByte
oStream.Position = 0
oStream.CharSet = “gb2312”
oStream.Position = 2
ByteToStr = oStream.ReadText
oStream.Close
Set oStream = Nothing
End Function
Private Function ItemToColl
For i = 0 To itemCount – 1
If Not Form.Exists(itemName(i)) Then
Form.Add itemName(i), itemData(i)
End If
Next
End Function
Private Sub Class_Terminate
Form.RemoveAll
Set Form = Nothing
End Sub
End Class
If Request.ServerVariables(“REQUEST_METHOD”) = “POST” Then
Rem 建立上传类实例
Set oUpload = New Upload
Rem 指定允许上传文件的类型
oUpload.CheckFields = “|GIF|BMP|JPG|”
Rem 指定上传文件所存储的相对路径
oUpload.Folder = “-ZMM/UploadFile”
Rem 开始上传处理
oUpload.Start
If oUpload.Finished Then
Rem 上传成功,显示上传信息
Dim sHtml : sHtml = “”
sHtml = sHtml & “”
sHtml = sHtml & “”
sHtml = sHtml & “上传表单数据
“
sHtml = sHtml & “标题:
” & oUpload.Form(“P_title”) & “
“
sHtml = sHtml & “类型:
” & oUpload.Form(“P_assort”) & “
“
sHtml = sHtml & “小图:
服务器端路径:” & oUpload.Form(“P_image_s”) & “
“
sHtml = sHtml & “中图:
服务器端路径:” & oUpload.Form(“P_image_m”) & “
“
sHtml = sHtml & “大图:
服务器端路径:” & oUpload.Form(“P_image_b”) & “
“
sHtml = sHtml & “介绍:
” & oUpload.Form(“P_content”) & “
“
sHtml = sHtml & “
“
sHtml = sHtml & “”
Response.Write sHtml
Response.End
Else
Rem 上传失败,显示错误信息
Call ShowMsg(oUpload.ErrMessage, Request.ServerVariables(“SCRIPT_NAME”))
End If
Rem 对话框提示函数
Function ShowMsg(byVal sText, byVal sTarget)
Dim sScript : sScript = “”
sScript = sScript & “” & vbCrlf & _“window.alert(‘” & sText & “‘);” & vbCrlf & _“window.location.replace(‘” & sTarget & “‘);” & vbCrlf & _“”
Response.Write sScript
Response.End
End Function
End If
%>
function formCheck(_form) {for (var i = 0; i < _form.elements.length; i ++) {if (_form.elements[i].value == \) { window.alert(请将表单填写完整,提交失败!); return false;}}return true;}
<form action="” method=”post” enctype=”multipart/form-data” onsubmit=”return formCheck(this);”>
上传功能测试 | |
标题: | |
类型
本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
最近发布
|