發表文章

目前顯示的是 9月, 2014的文章

身分證字號解析

範例: S101446784 分解算式: S  = 56(PS參考列表中的值) 1  =  1  * 8 = 8   + 56   = 64 0  =  0  * 7 = 0   + 64   = 64 1  =  1  * 6 = 6   + 64   = 70 4  =  4  * 5 = 20 + 70   = 90 4  =  4  * 4 = 16 + 90   = 106 6  =  6  * 3 = 18 + 94   = 124 7  =  7  * 2 = 14 + 112 = 138 8  =  8  * 1 = 8   + 138 = 146 4  =  4  + 146 = 150 150 / 10 求餘數是否為0如果是的話則此身分證為正確 參考列表: 值        代碼區分 ---------------------- 1        台北市A 10        台中市B 19        基隆市C 28        台南市D 37        高雄市E 46        台北縣F 55        宜蘭縣G 64        桃園縣H 39        嘉義市I 73        新竹縣J 82        苗栗縣K 2        台中縣L 11        南投縣M 20        彰化縣N 48        新竹市O 29        雲林縣P 38        嘉義縣Q 47        台南縣R 56        高雄縣S 65        屏東縣T 74        花蓮縣U 83        台東縣V 21        金門縣W 3        澎湖縣X 12        陽明山Y 30        連江縣Z C# public bool ChkID(String strID) {         // 英文字母代號對應 A-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         int[] intSID = { 1, 10, 19, 28, 37,

Content Type Mapping

/// <summary>       /// 用副檔名取得Content Type名稱       /// </summary>       /// <param name="Extension"></param>       /// <returns></returns>       public static String GetContentType(String ExtensionName)       {           String ContentType = String.Empty;           ExtensionName = (!ExtensionName.Substring(0, 1).Equals(".")) ? "." + ExtensionName : ExtensionName;           if (!_ContentTypeMapping.TryGetValue(ExtensionName, out ContentType))           {               ContentType = _ContentTypeMapping[".*"];           }           return ContentType;       }       /// <summary>       /// Content Type Index       /// </summary>       public static readonly System.Collections.Generic.IDictionary<string, string> _ContentTypeMapping =           new System.Collections.Generic.Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)       {           { ".*&quo

JavaScript 獲取頁面高度(多種瀏覽器)

function getInfo() {     var s = "";     s += " 網頁可見區域寬:"+ document.body.clientWidth;     s += " 網頁可見區域高:"+ document.body.clientHeight;     s += " 網頁可見區域寬:"+ document.body.offsetWidth + " (包括邊線和捲軸的寬)";     s += " 網頁可見區域高:"+ document.body.offsetHeight + " (包括邊線的寬)";     s += " 網頁正文全文寬:"+ document.body.scrollWidth;     s += " 網頁正文全文高:"+ document.body.scrollHeight;     s += " 網頁被卷去的高(ff):"+ document.body.scrollTop;     s += " 網頁被卷去的高(ie):"+ document.documentElement.scrollTop;     s += " 網頁被卷去的左:"+ document.body.scrollLeft;     s += " 網頁正文部分上:"+ window.screenTop;     s += " 網頁正文部分左:"+ window.screenLeft;     s += " 螢幕解析度的高:"+ window.screen.height;     s += " 螢幕解析度的寬:"+ window.screen.width;     s += " 螢幕可用工作區高度:"+ window.screen.availHeight;     s += " 螢幕可用工作區寬度:"+ window.screen.availWidth;     s += " 你的螢幕設置是 &

JQuery 針對 Selector的操作

1. 取得選擇項目的文字與值 /*----- 單選 -----*/ //  取得被選擇項目的文字 $("#select").find(":selected").text();   //  取得被選擇項目的值 $("#select").find(":selected").val();   /*----- 多選 -----*/ //  使用迴圈取得所有被選擇的項目 $("#select").find(":selected").each(function() {   alert(this.text);    //  文字   alert(this.value);   //  值 }); 2. 增加項目 $("#select").append($("<option></option>").attr("value", "值").text("文字")); 3. 移除選擇的項目 //  移除選擇的項目 $("#select").find(":selected").remove();   //  移除全部的項目 $("#select option").remove(); 4. 移除選擇項目後,防止捲軸移到最上面 //  先取得要移除項目的 index var selectIndex = $("#select").find(":selected").index();   //  移除選擇的項目 $("#select").find(":selected").remove();   //  判斷移除項目後,原先的index是否還有option,有的話就直接將此option設定為選取狀態 //  捲軸就不會往上跑了 if ($('#select option').get(selectIndex) != null) {     $('#select option

CSS3 螢幕大小區分

試試看吧 /* 全部的使用者都會載入這裡的 CSS。*/ @media screen and (min-width: 1200px) {     /* 如果使用者之視窗寬度 >= 1200px,將會再載入這裡的 CSS。;*/ } @media screen and (max-width: 1199px) {     /* 如果使用者之視窗寬度 >= 1200px,將會再載入這裡的 CSS。;*/ } @media screen and (min-width: 768px) and (max-width: 979px) {     /*如果使用者之視窗寬度介於 768px ~ 979px,將會再載入這裡的 CSS。*/ } @media screen and (max-width: 767px) {     /*如果使用者之視窗寬度 <= 768px,將會再載入這裡的 CSS。*/ } @media screen and (max-device-width: 480px) {     /*如果使用者之裝置寬度 <= 480px,將會再載入這裡的 CSS。*/ }