Microsoft AJAX Library 新特性簡單代碼

來源:互聯網
上載者:User

<form id="form1" runat="server">
<input id="ClkBtn" type="button" value="addClickOnBtn" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script language="javascript" type="text/javascript">

$addHandlers ($get ("ClkBtn"), {
    mouseover: onMouseOver,
    mouseout: onMouseOut
});

function onMouseOver (e) { this.style.backgroundColor = 'yellow'; }
function onMouseOut (e) { this.style.backgroundColor = 'white'; }

var article = Sys.UI.DomElement.getElementById('ClkBtn');
alert(article.value);

var article = $get('ClkBtn');
alert(article.value);

var article = $get('ClkBtn');
var position = Sys.UI.DomElement.getLocation(article);
var x = position.x, y = position.y;
alert(x);
alert(y);

var menu = $get('ClkBtn');
Sys.UI.DomElement.setLocation(menu, 500, 500);

var article = $get('ClkBtn');
var bounds = Sys.UI.DomElement.getBounds(article);
Sys.Debug.traceDump (bounds, 'Article position and size');

var a = ['a','b','c','d'];
var b = Array.clone(a);
alert(b);

var a = ['red','green','blue','yellow'];
var b = Array.contains(a, "red");
alert(b);

var myArray = [],result = "";
Array.add(myArray, 'a');
Array.add(myArray, 'b');
Array.add(myArray, 'c');
Array.add(myArray, 'd');
result = Array.dequeue(myArray);
alert(myArray);
alert(result);

 

var a = ['a', 'b', 'c', 'd'];
a[5] = 'e';
var result = '';
function appendToString(arrayElement, index, array) {
    result += arrayElement + this + index + ',';
}
Array.forEach(a, appendToString, '|');
alert(result);

 

var a = ['red', 'blue', 'green', 'blue'];
var myFirstIndex = Array.indexOf(a, "blue");
var mySecondIndex = Array.indexOf (a, "blue", (myFirstIndex + 1));
// myFirstIndex = 1, mySecondIndex = 3

alert(myFirstIndex);
alert(mySecondIndex);

var a = ['a', 'b', 'd', 'e'];
Array.insert(a, 2, 'c');
alert(a);

var a = Array.parse ("['red', 'blue', 'green']");
alert(a[0]);
alert(a[1]);
alert(a[2]);

 

var a = ['a', 'b', 'c', 'd', 'e'];
Array.remove(a, 'c');
alert(a);
Array.removeAt(a, 2);
alert(a);

</script>
 </form>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.