用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
BlueDestiny的公告
<script language="vbscript"> function vbGetGBCode(str) dim i, length, s length = len(str) for i=1 to length hexCode = hex(asc(str.charAt(i-1))) if (len(hexCode) mod 2) = 0 then s = s & "%" & mid(hexCode, 1, 2) if ( len(hexCode) = 4 ) then s = s & "%" & mid(hexCode, 3, 2) end if else s = s & "%0" & hexCode end if next vbGetGBCode = s end function </script> <SCRIPT language=JavaScript> /** * Blog javascript functions * script by blueDestiny, never-online * http://www.never-online.net */ // function all start function writeCookie(name, value, hours) { var expire = ""; if(hours != null) { expire = new Date((new Date()).getTime() + hours * 3600000); expire = "; expires=" + expire.toGMTString(); } document.cookie = name + "=" + escape(value) + expire; }; function readCookie(name) { var cookieValue = ""; var search = name + "="; if(document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; cookieValue = unescape(document.cookie.substring(offset, end)) } } return cookieValue; }; // simple addEvent function addEvent(o,w,f) { if (document.all) { o.attachEvent('on'+w, f); } else { o.addEventListener(w, f, false); } } String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)| /g, ''); }; String.prototype.vbEncode = function() { return vbGetGBCode(this); }; //window.onerror = function() { return true; }; // copy Html code function fnCopyCode(obj) { var rng = document.body.createTextRange(); rng.moveToElementText(obj); rng.scrollIntoView(); rng.select(); rng.execCommand("Copy"); rng.collapse(false); }; // save Html code function fnSaveCode(obj) { var winname = window.open('', '_blank', 'top=10000'); winname.document.open('text/html', 'replace'); winname.document.writeln(obj.value); winname.document.execCommand('saveas','','code.htm'); winname.close(); } // run Html code function fnRunHtmlCode(obj) { //try { //if (typeof(obj)=="string") obj=document.getElementById(obj); var wnd = window.open('', "_blank", ''); wnd.document.open('text/html', 'replace'); wnd.document.writeln(obj.value); wnd.document.close(); //} catch(ex) { alert(ex.message) }; }; function fnReadyToRunHTMLcode() { // if (ie) //try { (function readyToRunHtml() { var aTextarea = document.getElementsByTagName("textarea"); for (var i=0; i<aTextarea.length; i++) { var tx_obj = aTextarea[i]; if (tx_obj.className=="code_textarea" || tx_obj.style.width.toString()=="500" || tx_obj.getAttribute("class")=='code_textarea' ) { tx_obj.className = "code_textarea"; insertRunHtmlBtn(tx_obj); } } }()) function insertRunHtmlBtn(obj) { var wrapper = document.createElement("DIV"); wrapper.style.margin="10px 0 10px 0"; var runBtn = document.createElement("INPUT"); var copyBtn = document.createElement("INPUT"); var saveBtn = document.createElement("INPUT"); saveBtn.type = "button"; saveBtn.value = "Save Code"; copyBtn.type = "button"; copyBtn.value = "Copy Code"; runBtn.type = "button"; runBtn.value = "Run HTML Code"; addEvent(runBtn, "click", function() { fnRunHtmlCode(obj) }); addEvent(copyBtn, "click", function() { fnCopyCode(obj) }); addEvent(saveBtn, "click", function() { fnSaveCode(obj) }); obj.parentNode.insertBefore(wrapper, obj.nextSibling); wrapper.appendChild(runBtn); wrapper.appendChild(copyBtn); wrapper.appendChild(saveBtn); } //} catch (ex) {} } // track search engine with google and baidu function fnTrackSearchEngine() { var divs = document.getElementsByTagName("DIV"); for (var i=0; i<divs.length; i++) { if (divs[i].className=="postTitle" && (divs[i].innerHTML.toLowerCase().indexOf("<img")!=-1)) { var sv = divs[i].innerHTML; sv = sv.replace(/<(a|img|\/a)[^<>]*>/ig,""); sv = sv.replace(/<script.*>.*<\/script>/ig,"").trim(); var bd_href = 'http://www.baidu.com/s?wd=' +sv.vbEncode()+ '&cl=3'; var gg_href = 'http://www.google.com/search?hl=zh-CN&q=' +window.encodeURIComponent(sv)+ '&btnG=Google%E6%90%9C%E7%B4%A2&lr='; var track = document.createElement("DIV"); var sHtml = ""; sHtml += 'Track Search Engine By This Title ' + '[<a href="' +gg_href+ '" target="_blank" title="用google搜索此标题的页面">GooGle</a>]' + '[<a href="' +bd_href+ '" target="_blank" title="用baidu搜索此标题的页面">Baidu</a>]' ; track.style.margin = "3px 0 3px 0"; track.innerHTML = sHtml; divs[i].insertBefore(track); } } }; function fnFixWrapperPosition() { var mn = document.getElementById("main"); var lm = document.getElementById("leftmenu"); if (mn.offsetHeight>lm.offsetHeight) { lm.style.height = mn.offsetHeight; } else { mn.style.height = lm.offsetHeight; } } function fnInsertNavigatorMenu() { var div = document.createElement("DIV"); with (div.style) { position = "absolute"; top = "55px"; left = "10px" width = "420px"; height = "20px"; display = "block"; } document.body.appendChild(div); div.innerHTML = '<a href="javascript:void(fntoggleSiderbar(this))" style="text-decoration:none" title="display or hidden navigator">toggle sidebar</a> - <a href="http://www.never-online.net" style="text-decoration:none" target="_blank" title="go to my website">Visite Website</a> - <a href="mailto:blueDestiny#126.com" style="text-decoration:none" title="email to me">EMail to me</a> - <a href="http://wpa.qq.com/msgrd?V=1&Uin=77091373" style="text-decoration:none" target="_blank" title="Q me">Q me</a> '; } function fntoggleSiderbar(o) { var lm = document.getElementById("leftmenu"); var mn = document.getElementById("main"); if (lm.style.display == "none") { lm.style.display = ""; mn.style.marginLeft = "190px"; } else { lm.style.display = "none"; mn.style.marginLeft = "0"; } } function fnMsgDialog(msg, delay) { if (readCookie("msgDialog")==="true") return; var div = document.createElement("DIV"); div.id = "msgDialogWrapper"; document.body.appendChild(div); var htmls = '\ <div style="background-color:highlight;padding:6px;color:#fff;font-weight:bold;font-size:9pt;">短信息</div>\ <div style="padding:10px;line-height:200%;">\ 此消息一天只弹出一次,绝无任何广告:D<br/>\ ' +msg+ '\ </div>\ <div align="center" style="padding-bottom:10px;">\ <span id="_delayTime" style="padding-right:10px"></span>\ <input type="button" value="关闭" style="background-color:buttonface; padding-top:3px;border:2px outset buttonhighlight; color:#000; width:50px;" onclick="document.getElementById(\'msgDialogWrapper\').style.display=\'none\'"/>\ </div>\ ' var x=div.style; var w=window.innerWidth||document.body.clientWidth; var h=window.innerHeight||document.body.clientHeight; x.width="300px"; x.height="150px"; x.display="block"; x.position="absolute"; x.backgroundColor="buttonface"; x.fontSize="9pt"; x.padding="0px"; x.border="2px outset buttonhighlight" x.left = parseInt((w-div.offsetWidth)/2)+"px"; x.top = parseInt((h-div.offsetHeight)/2)+"px"; div.innerHTML = htmls; (function closeDialog() { document.getElementById("_delayTime").innerHTML = delay+"秒"; if (delay--!=0) window._timer=window.setTimeout(closeDialog,1000); else { x.display="none"; window.clearTimeout(window._timer); return; } }()) writeCookie("msgDialog","true",24); }; (function fnInsertSprite() { if (document.getElementById("sprite")) return; var sprite=document.createElement("DIV"); sprite.id="sprite"; document.getElementById("top").appendChild(sprite); }()); // function all end // run all function when page loaded. onload = function() { if (!document.getElementById) return; fnInsertNavigatorMenu(); fnReadyToRunHTMLcode(); fnMsgDialog( '点击 <a href="http://www.never-online.net/blog/" target="_blank">这里</a>进入我(BlueDestiny, never-online)的博客,CSDN我已经停止更新,所有的文章现在在新的域名上,有问题和建议,请在新博客上给我留言。' , 10); //fnTrackSearchEngine(); fnFixWrapperPosition(); } </script> <div style="padding:5px 5px 0 5px;"> Web: <br/>www.never-online.net<br/> Email: <br/>BlueDestiny##126.com<br/> QQ: <br/>77091373<br/> </div>
文章分类
JS & DHTML
Dhteumeuleu
Douglas Crockford
Webfx
常去之地
ASP.Net
MSDN英文
XML指南
XML的大本营
博客园
正则表达式
我的网站
我网站的Blog(RSS)
友情链接
KimSoft的blog(RSS)
存档

原创  JS控件autocomplete(自动完成)演示及下载 收藏

虽然没有预期的效果好,但还是先把代码及演示给大家。

演示及下载:
http://www.never-online.net/code/neverModules/autocomplete/

功能较上一版本的改进:
1。匹配速度的提高。
2。加入ignoreCase属性(为false时,将区分大小写,默认为true)
3。加入ignoreWhere属性(为true时,匹配结果将使用贪婪匹配,即整个字符串中只要有输入的字符,将把dataSource内容送入匹配结果中)
4。按esc返回。
5。兼容IE6.0, Opera9.0, Mozilla Firefox1.5
6。可手动清空dataSource数据,或动态赋值给dataSource。方便的进行AJAX,详细请看示例。
7。highlighted属性(默认为true,大数据量时,建议设置为false)。
8。在IE中,弥补div被select控件遮挡。详细请看第一个示例。 

发表于 @ 2006年09月13日 16:55:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:[js源码] neverModules - imagesLoader 图片加载类 | 新一篇:innerHTML在Mozilla Firefox和Opera下执行的一个特例情况。

  • 发表评论
  • 评论内容:
  •  
Copyright © BlueDestiny
Powered by CSDN Blog