2016年10月24日 星期一

jquery 自訂函數

自訂函數
$.fn.xxfunctionName = function() { ***** }

呼叫
$(selector).xxfunctionName(function(){
var selector=$(this);
});

參數問題 foo() , foo(a) , foo(a,b)
function foo(a, b) {   var aa = typeof a !== 'undefined' ? a : 42;   var bb = typeof b !== 'undefined' ? b : 'default_b';   ... }
e.stopPropagation(); 停止父層程序
e.preventDefault(); 停止預設訂做


 $('a[href$="ABC"]')...
= is exactly equal != is not equal ^= is starts with $= is ends with *= is contains ~= is contains word |= is starts with prefix (i.e., |= "prefix" matches "prefix-...")

2016年10月21日 星期五

下載區的限制設定

.htaccess

防止執行,僅限下載
# The following directives prevent the execution of script files
# in the context of the website.
# They also force the content-type application/octet-stream and
# force browsers to display a download dialog for non-image files.

SetHandler default-handler
ForceType application/octet-stream
Header set Content-Disposition attachment

# The following unsets the forced type and Content-Disposition headers
# for known image files:
<FilesMatch "(?i)\.(gif|jpe?g|png)$">
ForceType none
Header unset Content-Disposition
</FilesMatch>

# The following directive prevents browsers from MIME-sniffing the content-type.
# This is an important complement to the ForceType directive above:
Header set X-Content-Type-Options nosniff

# Uncomment the following lines to prevent unauthorized download of files:
#AuthName "Authorization required"
#AuthType Basic
#require valid-user
參考:
http://viralpatel.net/blogs/21-very-useful-htaccess-tips-tricks/
https://github.com/blueimp/jQuery-File-Upload/wiki/Security

2016年10月13日 星期四

table css

單數欄變底色

tr:nth-child(even){background-color: #f2f2f2}

表格防爆框
<div style="overflow-x:auto;">