2011年12月6日星期二

PHP計算字串相似度


$str1 = 'this is a pen.';
$str2 = 'is this a pen?';
similar_text($str1, $str2, $percent);
echo $percent;

2011年12月5日星期一

javascript移除千分位符號

xyz = parseInt(xyz.replace(",",""),10);

在A標籤中使用onclick=location.href進行轉頁

在A標籤中使用onclick=location.href進行轉頁

範例:
<a href='http://tw.yahoo.com' onclick="location.href='http://www.google.com/';return false;">test</a>

重點在於紅字部分的 return false;,讓href的內容失效。