Skip to content

Instantly share code, notes, and snippets.

@WenLiangTseng
WenLiangTseng / front_end.php
Last active December 20, 2015 01:39
讓HTML的一個Option取多個數值
<!-- put values for each options like -->
<SELECT NAME="val">
<OPTION VALUE="1" value="1:2:3:4"> 1-4
<OPTION VALUE="2" value="5:6:7:8"> 5-8
<OPTION VALUE="3" value="9:10:11:12"> 9-12
</SELECT>
@WenLiangTseng
WenLiangTseng / basic.css
Created July 22, 2013 00:33
CSS內嵌基本格式
<style type="text/css">
body {
font-size: 10pt;
line-height: 1.2em
}
</style>
@WenLiangTseng
WenLiangTseng / favicon.php
Last active December 20, 2015 01:39
favicon 寫法
<!-- PNG -->
<link rel="icon" type="image/png" href="http://www.example.com/png-favicon.png" />
<!-- JPG -->
<link rel="icon" type="image/jpeg" href="/jpeg-favicon.jpg" />
<!-- GIF -->
@WenLiangTseng
WenLiangTseng / html5_basic_format.php
Last active December 20, 2015 01:39
HTML5基本格式
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<!--[if IE]>
@WenLiangTseng
WenLiangTseng / html5_full_format.php
Last active December 20, 2015 01:39
HTML5完整格式
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<!--[if IE]>
@WenLiangTseng
WenLiangTseng / show_current_system_time.js
Last active December 20, 2015 01:39
JavaScript顯示目前系統時間
<script type="text/javascript">
<!--
var d = new Date();
var curr_hour = d.getHours();
var curr_min = d.getMinutes();
document.write(curr_hour + " : " + curr_min);
@WenLiangTseng
WenLiangTseng / jQuery_unwrap.js
Created July 22, 2013 00:50
jQuery 去除一個元素本身的 HTML Tag
$('b').contents().unwrap();
//For the greatest performance, always go native:
var b = document.getElementsByTagName('b');
while(b.length) {
var parent = b[ 0 ].parentNode;
while( b[ 0 ].firstChild ) {
@WenLiangTseng
WenLiangTseng / taiwan_address_auto_change.js
Last active December 20, 2015 01:39
連動式地址下拉選單-原版
var app = window.AddressSeleclList =
{
AdrressArray: [
['台北市', '100中正區', '103大同區', '104中山區', '105松山區', '106大安區', '108萬華區', '110信義區', '111士林區', '112北投區', '114內湖區', '115南港區', '116文山區'],
['台北縣', '207萬里鄉', '208金山鄉', '220板橋市', '221汐止市', '222深坑鄉', '223石碇鄉', '224瑞芳鎮', '226平溪鄉', '227雙溪鄉', '228貢寮鄉', '231新店市', '232坪林鄉', '233烏來鄉', '234永和市', '235中和市', '236土城市', '237三峽鎮', '238樹林市', '239鶯歌鎮', '241三重市', '242新莊市', '243泰山鄉', '244林口鄉', '247蘆洲市', '248五股鄉', '248新莊市', '249八里鄉', '251淡水鎮', '252三芝鄉', '253石門鄉'],
['台中市', '400中區', '401東區', '402南區', '403西區', '404北區', '406北屯區', '407西屯區', '408南屯區'],
['台中縣', '411太平市', '412大里市', '413霧峰鄉', '414烏日鄉', '420豐原市', '421后里鄉', '422石岡鄉', '423東勢鎮', '424和平鄉', '426新社鄉', '427潭子鄉', '428大雅鄉', '429神岡鄉', '432大肚鄉', '433沙鹿鎮', '434龍井鄉', '435梧棲鎮', '436清水鎮', '437大甲鎮', '438外埔鄉', '439大安鄉'],
['台東縣', '950台東市', '951綠島鄉', '952蘭嶼鄉', '953延平鄉', '954卑南鄉', '955鹿野鄉', '956關山鎮', '957海端鄉', '958池上鄉', '959東河鄉', '961成功鎮', '962長濱
@WenLiangTseng
WenLiangTseng / fancybox_set_iframe_width_height.js
Created July 22, 2013 02:23
FancyBox 設定 iframe 的寬度和高度
/*FancyBox-設定 iframe 的 寬度和高度
FancyBox很漂亮的陰影效果,
還可以放圖片、內連、ajax和 iframe內容
檔案不大,使用也很簡單。
英文官網:http://fancybox.net/
中文說明:http://www.icyfire.me/2009/07/jqueryfancybox/
但有個bug,就是內容為 iframe 的時候,
寬度和高度的設定沒作用
@WenLiangTseng
WenLiangTseng / check_if_email_validate.js
Created July 22, 2013 02:25
JavaScript 偵測表單信箱格式是否正確
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
};