//自定义的apply,call
Function.prototype.apply =
function (obj, argu) {
if (obj) obj.constructor.prototype._caller =
this ;
var argus =
new Array ();
for (
var i=0;i
argus[i] = "argu[" + i + "]" ; var r; eval("r = " + (obj ? ("obj._caller(" + argus.join("," ) + ");" ) : ("this(" + argus.join("," ) + ");" ))); return r; }; Function.prototype.call = function (obj) { var argu = new Array (); for (var i=1;i argu[i-1] = arguments[i]; return this .apply(obj, argu); };
//下载文件
function DownURL(strRemoteURL,strLocalURL) { try { var xmlHTTP=new ActiveXObject ("Microsoft.XMLHTTP" ); xmlHTTP.open("Get" ,strRemoteURL,false ); xmlHTTP.send(); var adodbStream=new ActiveXObject ("ADODB.Stream" ); adodbStream.Type=1;//1=adTypeBinary adodbStream.Open(); adodbStream.write(xmlHTTP.responseBody); adodbStream.SaveToFile(strLocalURL,2); adodbStream.Close(); adodbStream=null ; xmlHTTP=null ; } catch (e) { window.confirm("下载URL出错!" ); } //window.confirm("下载完成." ); }
//检验连接是否有效
function getXML(URL) { var xmlhttp = new ActiveXObject ("microsoft.xmlhttp" ); xmlhttp.Open("GET" ,URL, false ); try { xmlhttp.Send(); } catch (e){} finally { var result = xmlhttp.responseText; if (result) { if (xmlhttp.Status==200) { return (true ); } else { return (false ); } } else { return (false ); } } }
//POST代替FORM
//readyState是xmlhttp返回数据的进度,0=载入中,1=未初始化,2=已载入,3=运行中,4=完成
//检查网页是否存在
function CheckURL(URL) { var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP" ); xmlhttp.Open("GET" ,URL, false ); try { xmlhttp.Send(); var result = xmlhttp.status; } catch (e) {return (false ); } if (result==200) { return true ; } xmlhttp = null ; return false ; }
//连接数据库
//使用数据岛
srno: "76" > times: "76" > "first" TYPE=button value="<< 第一条记录" onclick="xmldate.recordset.moveFirst()" > "prev" TYPE=button value="<上一条记录" onclick="xmldate.recordset.movePrevious()" > "next" TYPE=button value="下一条记录>" onclick="xmldate.recordset.moveNext()" > "last" TYPE=button value="最后一条记录>>" onclick="xmldate.recordset.moveLast()" > "Add" TYPE=button value="添加新记录" onclick="xmldate.recordset.addNew()" > "xmldate"> 20041025-01 null 20041101-09 2004年10月1日2点22分0秒
//获得参数
//可编辑Select
"width:100px;height:21px;font-size:10pt;">"width:18px;border:0px solid red;" >"r00" style="margin-left:-100px;width:118px; background-color:#FFEEEE;" onChange="document.all.re_name.value=this.value;" > "1">11111111 "2">222222 "3">333333
//设置光标位置
function getCaret(textbox) { var control = document.activeElement; textbox.focus(); var rang = document.selection.createRange(); rang.setEndPoint("StartToStart" ,textbox.createTextRange()) control.focus(); return rang.text.length; } function setCaret(textbox,pos) { try { var r =textbox.createTextRange(); r.moveStart('character',pos); r.collapse(true ); r.select(); } catch (e) {} } function selectLength(textbox,start,len) { try { var r =textbox.createTextRange(); r.moveEnd('character',len-(textbox.value.length-start)); r.moveStart('character',start); r.select(); } catch (e) {//alert(e.description)} } function insertAtCaret(textbox,text) { textbox.focus(); document.selection.createRange().text = text; }
//页内查找
function findInPage(str) { var txt, i, found,n = 0; if (str == "" ) { return false ; } txt = document.body.createTextRange(); for (i = 0; i <= n && (found = txt.findText(str)) != false ; i++) { txt.moveStart("character" , 1); txt.moveEnd("textedit" ); } if (found) { txt.moveStart("character" , -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } else { if (n > 0) { n = 0; findInPage(str); } else { alert(str + "... 您要找的文字不存在。
\n请试着输入页面中的关键字再次查找!" ); } } return false ; }
//书
//自定义提示条
//插入文字
document.onclick =function (){ var oSource = window.event.srcElement; if (oSource.tagName!="DIV" ) return false ; var sel = document.selection; if (sel!=null ) { var rng = sel.createRange(); if (rng!=null ) rng.pasteHTML("插入文字 " ); } }
//netscapte下操作xml
doc = new ActiveXObject ("Msxml2.DOMDocument" ); doc = new ActiveXObject ("Microsoft.XMLDOM" ) ->> doc = (new DOMParser()).parseFromString(sXML,'text/xml')
//判断键值
"Content-Type" content="text/html; charset=gb2312" > //Javascript Document.
请按任意一个键。。。。
//禁止FSO
1.注销组件 regsvr32 /u scrrun.dll 2.修改PROGID HKEY_CLASSES_ROOT\Scripting.FileSystemObject Scripting.FileSystemObject 3.对于使用object的用户,修改HKEY_CLASSES_ROOT\Scripting.
//省略号
"width: 120px; height: 50px; border: 1px solid blue; overflow: hidden; text-overflow:ellipsis"> 就是比如有一行文字,很长,表格内一行显示不下.
//检测media play版本
"oClientCaps" style="{behavior:url(#default#clientcaps)}" /> <SCRIPT> <br><span style="COLOR: #0000ff">var</span> flash=<span style="COLOR: #ff00ff">""</span>; <br> WMPVersion= oClientCaps.getComponentVersion(<span style="COLOR: #ff00ff">"{22D6F312-B0F6-11D0-94AB-0080C74C7E95}"</span>,<span style="COLOR: #ff00ff">"ComponentID"</span>); <br> <span style="COLOR: #0000ff">if</span> (WMPVersion != <span style="COLOR: #ff00ff">""</span>) { <br> flash = <span style="COLOR: #ff00ff">""</span>; <br> <span style="COLOR: #0000ff">var</span> version = WMPVersion.split(<span style="COLOR: #ff00ff">","</span>); <br> <span style="COLOR: #0000ff">var</span> i; <br> for (i = 0; i < version.length; i++) { <BR> <SPAN style="COLOR: #0000ff">if</SPAN> (i != 0) <BR> flash += <SPAN style="COLOR: #ff00ff">"."</SPAN>; <BR> flash += version[i]; <BR> } <BR> document.write(<SPAN style="COLOR: #ff00ff">"您的Windows Media Player 版本是:"</SPAN>+flash+<SPAN style="COLOR: #ff00ff">"<p>"); <br> } <br></SCRIPT>
//图象按比例
".." onload =
"DrawImage(this)" >
//细线Select
<span style="border:1px solid #000000; position:absolute; overflow:hidden;" > <select style="margin:-2px;" > <option >1111</option > <option >11111111111111</option > <option >111111111</option > </select ></span >
//Import
function Import() {
for(
var i=0; i
var file = arguments[i]; if ( file.match(/\.js$/i)) document.write('
//取得innerText
//mergeAttributes 复制所有读/写标签属性到指定元素。
<SCRIPT> <br><span style="COLOR: #0000ff">function</span> fnMerge(){ <br>oSource.children[1].mergeAttributes(oSource.children[0]); <br>} <br></SCRIPT>
ID="oDiv" ATTRIBUTE1="true" ATTRIBUTE2="true" onclick="alert('click');" onmouseover="this.style.color='#0000FF';" onmouseout="this.style.color='#000000';" > This is a sample DIV element.
"oDiv2"> This is another sample DIV element.
TYPE=
"button" VALUE=
"Merge Attributes" onclick=
"fnMerge()" >
将选中内容保存为html
New Document "Generator" CONTENT=
"EditPlus" >
"Author" CONTENT=
"" >
"Keywords" CONTENT=
"" >
"Description" CONTENT=
"" >
显示版块帖子 版块帖子分页 显示单个帖子 发送新帖 帖子回复 个人登陆 留言的回复功能 "save()" value=
"aa" >
判断是刷新还是离开
判断是刷新还是关闭-www.51windows.Net "Content-Type" content="text/html; charset=gb2312" > "Author" CONTENT="51windows,海娃,haiwa" > "Description" CONTENT="Power by 51windows.Net" > <script> <br><span style="COLOR: #0000ff">function</span> CloseOpen() { <br> <span style="COLOR: #0000ff">if</span>(event.clientX<=0 && event.clientY<0) { <br> alert(<span style="COLOR: #ff00ff">"关闭"</span>); <br> } <br> else <br> { <br> alert(<span style="COLOR: #ff00ff">"刷新或离开"</span>); <br> } <br>} <br></script> "CloseOpen()">
获得光标位置
TextRange의 일반적인 메서드
collapse([bStart]) 선택 항목 축소 및 Range 삽입 지점 이동 bStart true (처음으로 이동, 기본값) false (이동 to End) expand(sUnit) 단위에 포함된 선택 항목이 포함되도록 선택 항목을 확장합니다. findText(sText [, iSearchScope] [, iFlags]) 범위 검색 sText iSearchScope 시작 위치, 음수 방향 검색 iFlags 1(뒤로 검색) 2(전체 단어 일치) 4(대소문자 구분) moveStart(sUnit [, iCount]) moveEnd(sUnit [, iCount]) 범위의 시작 또는 끝 이동 sUnit 문자(단어) 단어(단어) 문장(문장) textedit(Range) iCount 이동 횟수, 기본값은 1 moveToPoint(iX, iY) 커서를 좌표(iX, iY)로 이동 pasteHTML(sHTMLText) 범위의 HTML 바꾸기 scrollIntoView([ bAlignToTop]) 현재 창에 표시하려면 스크롤 bAlignToTop true (범위는 창의 시작 부분에 있음) false (범위는 다음 위치에 있음) 창 하단) 선택() 선택 상태로 두기
이벤트 소스 개체 event.srcElement.tagName event.srcElement.type
캡처 해제 event.srcElement.setCapture() event.srcElement.releaseCapture();
이벤트 키 event.keyCode event.shiftKey event.altKey event.ctrlKey
이벤트 반환값 event.returnValue
마우스 위치 event.x event.y
양식 활성 요소 document.activeElement
이벤트 바인딩 document.captureEvents(Event.KEYDOWN);
양식 요소 액세스 document.all("txt").focus(); document.all("txt").select();
양식 명령 document.execCommand
쿠키 만들기 document.cookie
메뉴 이벤트 document.oncontextmenu
요소 생성 document.createElement("SPAN")
마우스를 기준으로 요소 가져오기: document.elementFromPoint(event.x,event.y).tagName=="TD document.elementFromPoint (event.x,event.y).appendChild(ms)
양식 이미지 document.images[색인]
양식 이벤트 바인딩 document.onmousedown=scrollwindow;