Javascript 重新載入或關閉瀏覽器的觸發JS

不小心發現的功能. 爬了一下google.

Onbeforeunload 是正要去Server讀取資料時觸發的,此時尚未開始讀取。

onunload 己從Server讀取完新資料,在即將更新畫面時所觸發的。

Onunload 無法阻止頁面的更新與關閉。而 Onbeforeunload 可以做到。

用法一

<script type="text/javascript"">
<!--
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){ ... }
function onunload_handler(){ ... }
// --">
</script">

用法二

<body onbeforeunload="checkLeave()">

<body onunload="checkLeave()">


資料來源:http://www.iteye.com/topic/269213

更詳細的說明:http://xieyu.blog.51cto.com/213338/55796/

當colorbox蓋不過flash時

當使用colorbox時. 發現youtube影片會在上面時. 可以使用以下方法解決

在網址後加 ?wmode=transparent

<iframe> width="420" height="315" src="http://www.youtube.com/embed/nGeKSiCQkPw?wmode=transparent" frameborder="0" allowfullscreen></iframe>

資料來源:http://thewichitacomputerguy.com/blog/z-index-flash-objects-thickbox-fix

MySql 把字串連接起來 - CONCAT()

MySql中把字串連接起來可以使用 CONCAT()

CONCAT(string1, string2, string3, …)

用法. update xxxx set CONCAT(欄位一, '--', 欄位二) where .....

PHP 去除HTML和PHP標籤 - strip_tags


去除字串中的HTML和PHP標籤

【轉載】PHP 程式效能優化的 40 條建議


資料來源:http://cychiang719.blogspot.tw/2008/02/php-40.html