//各種尺寸網頁可見地區寬:document.body.clientWidth; 網頁可見地區高:document.body.clientHeight; 網頁可見地區高:document.body.offsetWeight(包括邊線的寬) 網頁可見地區高:document.body.offsetHeight(包括邊線的寬) 網頁本文全文寬:document.body.scrollWidth; 網頁本文全文高:document.body.scrollHeight; 網頁被捲去的高:document.body.scrollTop; 網頁被捲去的左:document.body.scrollLeft; 網頁本文部分上:window.screenTop; 網頁本文部分左:window.screenLeft; 螢幕解析度的高:window.screen.height; 螢幕解析度的寬:window.screen.width; 螢幕可用工作區高度:window.screen.availHeight; 螢幕可用工作區寬度:window.screen.availWidth; |
//過濾數字return event.keyCode>=48&&event.keyCode<=57||(this.value.indexOf(".")<0? event.keyCode==46:false) onpaste="return !clipboardData.getData("text").match (/D/)" ondragenter="return false"> |
//特殊用途window.external.ImportExportFavorites(true,"http://localhost");匯入收藏夾 window.external.ImportExportFavorites(false,"http://localhost"); 匯出收藏夾 window.external.ShowBrowserUI("OrganizeFavorites", null); 整理收藏夾 window.external.ShowBrowserUI("LanguageDialog", null) 語言設定 window.external.AddFavorite("http://www.google.com/", "google") 加入收藏夾 window.external.addChannel("http://www.google.com/") 加入到頻道 window.external.showBrowserUI("PrivacySettings",null) |
//不緩衝<"pragma" CONTENT="no-cache"> <"Cache-Control" CONTENT="no-cache, must- revalidate"> <"expires" CONTENT="0"> |
//正則匹配匹配中文字元的Regex: [u4e00-u9fa5] 匹配雙位元組字元(包括漢字在內):[^x00-xff] 匹配空行的Regex: [s| ]* 匹配HTML標記的Regex:/< (.*)>.*</1>|<(.*) />/ 匹配首尾空格的Regex:(^s*)|(s*$)(像vbscript那樣的trim函數) 匹配Email地址的Regex:w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)* 匹配網址URL的Regex:http://([w-]+.)+[w-]+(/[w- ./?%&=]*)? 以下是例子: 利用Regex限制網頁表單裡 的文字框輸入內容: 用Regex限制只能輸入中文:onkeyup="value=value.replace(/[^u4E00- u9FA5]/g,"")" onbeforepaste="clipboardData.setData("text",clipboardData.getData ("text").replace(/[^u4E00-u9FA5]/g,""))" 1.用Regex限制只能輸入全形字元: onkeyup="value=value.replace(/[^uFF00-uFFFF]/g,"")" onbeforepaste="clipboardData.setData("text",clipboardData.getData("text").replace(/[^uFF00-uFFFF]/g,""))" 2.用正則表 達式限制只能輸入數字:onkeyup="value=value.replace(/[^d]/g,"") "onbeforepaste="clipboardData.setData("text",clipboardData.getData("text").replace(/[^d]/g,""))" 3.用正則 運算式限制只能輸入數字和英文:onkeyup="value=value.replace(/[W]/g,"") "onbeforepaste="clipboardData.setData("text",clipboardData.getData("text").replace (/[^d]/g,""))" |
//消除映像工具列height="100" alt="" width="100" galleryimg="false" or <"imagetoolbar" content="no"> |
//無提示關閉function Close() { var ua=navigator.userAgent var ie=navigator.appName== "Microsoft Internet Explorer"? true:false if(ie) { var IEversion=parseFloat(ua.substring(ua.indexOf( "MSIE ") +5,ua.indexOf(";",ua.indexOf("MSIE ")))) if(IEversion< 5.5) { var str = "clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">" str += ""Command"?value="Close">"; document.body.insertAdjacentHTML("beforeEnd", str); document.all.noTipClose.Click(); } else { window.opener =null; window.close(); } } else { window.close() } } |
//取得控制項得絕對位置(1)<script language= "javascript"> function getoffset(e) { var t=e.offsetTop; var l=e.offsetLeft; while(e=e.offsetParent) { t+=e.offsetTop; l+=e.offsetLeft; } var rec = new Array(1); rec[0] = t; rec[1] = l; return rec } |
//獲得控制項的絕對位置(2)oRect = obj.getBoundingClientRect(); oRect.left oRect. |
//最小化,最大化,關閉"clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">? "Command"?value="Minimize">? "clsid:ADB880A6-D8FF-11CF-9377- 00AA003B7A11">? "Command"?value="Maximize">? "clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">? "Command"?value="Close">? |
//游標停在文字最後"javascript"> function?cc() { ? var?e?=?event.srcElement; ? var?r?=e.createTextRange(); ? r.moveStart("character",e.value.length); ? r.collapse(true); ? r.select(); } "123"?onfocus="cc()"> |
//頁面進入和退出的特效進入頁面"Page-Enter"?content="revealTrans (duration=x,?transition=y)"> 推出頁面"Page- Exit"?content="revealTrans(duration=x,?transition=y)">? 這個 是頁面被載入和調出時的一些特效。duration表示特效的期間,以秒為單位。transition表示使 用哪種特效,取值為1-23: 0?矩形縮小? 1?矩形擴大? 2?圓形縮小 3?圓形擴大? 4?下到 上重新整理? 5?上到下重新整理 6?左到右重新整理? 7?右到左重新整理? 8?豎百葉 窗 9?橫百葉窗? 10?錯位橫百葉窗? 11?錯位豎百葉窗 12?點擴散? 13?左右到中間重新整理? 14?中間到左右重新整理 15?中間到上下 16?上下到中間 ? 17?右下到左上 18?右上到左下? 19?左上到右下? 20?左下到右 上 21?橫條? 22?豎條? |
//網頁是否被檢索 "ROBOTS"?content="屬性值"> 其中屬性值有以下一些: 屬性值為"all":?檔案將被檢索,且頁上連結可被查詢; 屬性值為"none":?檔案不被檢索,而且不查詢頁上的連結; 屬性值為"index":?檔案將被檢索; 屬性值為"follow":?查詢頁上的鏈 接; 屬性值為"noindex":?檔案不檢索,但可被查詢連結; 屬性值為"nofollow":? |