下午1點35分,一隻黑貓叼了個箱子來按門鈴...
2011年12月18日 星期日
2011年12月8日 星期四
2011年12月7日 星期三
2011年6月5日 星期日
2011年5月17日 星期二
2011年5月16日 星期一
2011年5月11日 星期三
設定/取得/移除DOM物件的style屬性
有兩種方法...
方法1: 適用IE9及其他非IE瀏覽器
方法2: 適用IE系列
參考資料:Style handling methods in JavaScript
方法1: 適用IE9及其他非IE瀏覽器
obj.style.setProperty("background-color", "green");
obj.style.getPropertyValue("background-color");
obj.style.removeProperty("background-color");
方法2: 適用IE系列
obj.style.setAttribute("backgroundColor", "green");
obj.style.getAttribute("backgroundColor");
obj.style.removeAttribute("backgroundColor");
加上判斷瀏覽器類別,就一次搞定了
<html>
<head>
<script type="text/javascript">
function testMethod() {
var browser=navigator.userAgent;
var myDiv=document.getElementById("myDiv");
if(browser.search("MSIE")>-1){
alert(myDiv.style.getAttribute("backgroundColor"));
myDiv.style.removeAttribute("backgroundColor");
myDiv.style.setAttribute("backgroundColor", "green");
alert(myDiv.style.getAttribute("backgroundColor"));
}else{
alert(myDiv.style.getPropertyValue("background-color"));
myDiv.style.removeProperty("background-color");
myDiv.style.setProperty("background-color", "green");
alert(myDiv.style.getPropertyValue("background-color"));
}
}
</script>
</head>
<body>
<div id="myDiv" style="background-color: red; height: 50px; width: 50px"></div><br />
<input type="button" value="T E S T" onclick="testMethod()" />
</body>
</html>
參考資料:Style handling methods in JavaScript
標籤:
程式筆記,
Javascript
2011年5月10日 星期二
2011年3月29日 星期二
2011年2月28日 星期一
2011年2月23日 星期三
2011年2月18日 星期五
Oracle OCI-22053 錯誤
早上測試的時候程式噴了個錯誤給我
沒看過的error,只好來去拜Google神
原來是Oracle裡算出的數字長度過長,回傳到DataTable時發生溢位
比如說 1/3=0.333333333.....
解決的方法就是在查詢時 TO_CHAR 或 ROUND 就好了
參考資料
http://www.dotblogs.com.tw/puma/archive/2009/05/23/8536.aspx
筆記一下~
沒看過的error,只好來去拜Google神
原來是Oracle裡算出的數字長度過長,回傳到DataTable時發生溢位
比如說 1/3=0.333333333.....
解決的方法就是在查詢時 TO_CHAR 或 ROUND 就好了
參考資料
http://www.dotblogs.com.tw/puma/archive/2009/05/23/8536.aspx
筆記一下~
2011年1月6日 星期四
using 筆記
using 很好用,用using陳述式包起來的物件,在using陳述式結束時,會自動釋放資源,programmer就不用去煩惱記憶體管理的問題
不過用了這麼久,忽然對一些地方有點疑惑,於是google了一下,把找到的結果memo在這邊
不過用了這麼久,忽然對一些地方有點疑惑,於是google了一下,把找到的結果memo在這邊
- 物件必須實作 IDisposable 介面,這樣在結束時才能自動呼叫 Dispose()
- 物件最好在using子句內宣告,而不要在using外宣告,避免using後的程式碼存取到該物件而造成例外。(因為物件已被Dispose)
- 因為 using 的特性是會呼叫 Dispose(),這會呼叫到 Close(),所以在 using 區塊中不要呼叫 Close(),避免因二次呼叫 Close() 而造成例外
- using裡只有try final,而沒有catch區塊,因此using不會捕捉及處理例外狀況,如果怕出現預期外的錯誤的話,要自己寫catch
資料來源









