1.JavaScript取整數
a = 1.23456
進一法 : Math.ceil(a);
去尾法 : Math.floor(a);
四捨五入 : Math.round(a);
2.取得日期字串
<script language="JavaScript">
theDate = new Date();
document.write(theDate.toLocaleString());
</script>
3.利用jquery取得html id 物件的zhi
//值設定到Html
$("#RelationKey").html(param);
//從html讀值回來
var htmlStr = $("#RelationKey").html();
4.在動態建立table 的 時候,順便建立td的click 事件(呼叫updateRelation)
tr = tbody.insertRow(tbody.rows.length);
td = tr.insertCell(tr.cells.length);
//2011-01-09 新的功能,增加td click事件,可以直接更新某個ID的值
//td.setAttribute('onclick', 'updateRelation("'+fieldKeyValue+'","'+fieldNameValue+'")'); //IE 無法使用
td.onclick = function(){ updateRelation(fieldKeyValue,fieldNameValue); }; //IE也是不可以
td.innerHTML = fieldNameValue;
5./*DIV 可以左右並排*/ 上左左 3個一組
DIV#code
{
BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 50%; PADDING-RIGHT: 0px; BACKGROUND: #BF6A30; FLOAT: left; HEIGHT: 445px; BORDER-TOP: 0px; BORDER-RIGHT: 0px; PADDING-TOP: 0px
}
DIV#result
{
PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 49%; PADDING-RIGHT: 0px; BACKGROUND: #880000; FLOAT: left; HEIGHT: 445px; PADDING-TOP: 0px
}
DIV#butt {
BACKGROUND: #c8d7e3; HEIGHT: 40px
}
http://blog.csdn.net/myyate/archive/2008/07/31/2750488.aspx
5.向輸入元素增加事件處理程序
向輸入元素增加事件處理程序應該與使用setAttribute方法並指定事件程序的名字和所需函數程序的名字一樣容易,對嗎?錯。設置元素的事件處理程序的標準做法是使用元素的 setAttribute方法,它以事件名作為屬性名,並把函數處理程序作為屬性值,如下所示:
var formElement = document.getElementById("formElement");
formElement.setAttribute("onclick","doFoo();");
除了IE,上面的代碼在所有當前瀏覽器中都能工作,如果在IE中使用Javascrīpt設置 的事件處理程序,必須對元素使用點記法來引用所需的事件處理程序,並把它賦為匿名函數, 這個匿名函數要調用所需要的事件處理程序,如下所示:
var formElement = documentgetElementById("formElement");
formElement.onclick = function(){ doFoo(); };
幸運的是,這種技術得到了IE和所有其他當前瀏覽器的支持,所以完全可以通過 Javascrīpt動態地設置表單元素的事件處理程序。
======================================================================
IE 配合 jQuery 的.get / .post 時候如有中文字(utf-8)的時候, 有時候會亂碼 ,但是 FF卻不會亂碼,有兩種方法可以解決
1. 用 .get 的解決方式
var s2=encodeURIComponent("大家好");
var getdata=『bu_pkeyname='+s2;
$.get('update.aspx',getdata,function(data){ refres(id,name); },'text');
2.用.post的解決方式
var s2="大家好";
var getdata=『bu_pkeyname='+s2;
$.post('update.aspx',getdata,function(data){ refres(id,name); },'text');
======================================================================
在使用jquery的時候,如果連續2次以上非同步.get資料的時候,會造成回應結果錯位,所以在做2次以上的是一定要是同步方式,一次做完在做下一次
請在加上這個async:false,
$.ajax({
type:"GET",
async:false,
cache:false,
..........................
..........................
======================================================================
用jQuery來讀取cookie
Download the jQuery cookie plugin here: http://plugins.jquery.com/project/Cookie
Note that I am not the author of this plugin.
Setting a cookie with jQuery is as simple as this, where a cookie is created called "example" with a value of "foo":
$.cookie("example", "foo");
This is a session cookie which is set for the current path level and will be destroyed when the user exits the browser. To make the same cookie last for e.g. 7 days do this:
$.cookie("example", "foo", { expires: 7 });
To explicitly make the cookie available for all paths on your domain, make sure the path is set:
$.cookie("example", "foo", { path: '/'
});
To limit it to a specific path instead:
$.cookie("example", "foo", { path: '/admin'
});
Getting the cookie's value is also very easy with jQuery. The following would show the value of the "example" cookie in a dialog window:
alert( $.cookie("example") );
And finally, to delete a cookie set the value to null. Setting it to e.g. an empty string doesn't remove it; it just clears the value.
$.cookie("example", null);
http://www.electrictoolbox.com/jquery-cookies/
======================================================================
jQuery Select Opntion 與 Value
//jQuery的寫法,設定select 的option value,option vale都會有單引號,所以取得的文字使用要加單引號
$('#bu_pkey').val("'"+nodevalue+"'");
//jQuery的寫法,讀取select 的option value,
var s1=$('#tb_pkey').val();//取得value(Key)
var s2=$('#tb_pkey :selected').text();//取得text(名稱)
======================================================================
http://www.dotblogs.com.tw/kirkchen/archive/2010/08/18/17282.aspx
[C#]在 .Net 上實現 Win Form 中 MessageBox 的確認視窗
http://www.dotblogs.com.tw/willy0080/archive/2009/10/09/10984.aspx
公文轉發流程自定義的數據建模
http://big5.webasp.net/article/20/19719.htm
http://creativepony.com/archive/demos/sliding-tabs/
http://webdesignledger.com/tutorials/11-useful-jquery-tab-navigation-solutions
ASP.NET 2.0 使用資料表動態產生TreeView的樹狀結構
http://blog.blueshop.com.tw/topcat/archive/2005/12/07/15393.aspx