javascriptÉè¼Æģʽ֮¡¾µ¥Ìåģʽ¡¿
µ¥Ìåģʽ£¨singleton£©
µ¥ÌåÊÇÔڽű¾¼ÓÔØʱ´´½¨µÄ£¬Äܽ«Ò»ÏµÁÐÓйØÁªµÄ±äÁ¿ºÍ·½·¨×é֯Ϊһ¸öÂß¼µ¥Ôª£¬Âß¼µ¥ÔªÀïÃæµÄÄÚÈÝͨ¹ýµ¥Ò»µÄ±äÁ¿½øÐзÃÎÊ£»
Ò»¸öµ¥ÌåÖ÷Òª·ÖΪÈý²¿·Ö
ÓÃÓÚ·ÃÎÊÄÚ²¿ÐÅÏ¢µÄÈë¿Ú±äÁ¿£¨È磺Sky£©
ÊôÐÔ£¨È磺nickName/age/timeInfo£©
·½·¨£¨È磺sayHello£©
»ù±¾½á¹¹
01
var Sky = {
02
03
/*
04
* ×÷ÓÃÒ»£¬±äÁ¿¹ÜÀí
05
*/
06
07
nickName: "sky",
08
age: "26",
09
10
/*
11
* ×÷Óöþ£¬¼ÓÔØÖгõʼ»¯±äÁ¿
12
* ÔÚ¼ÓÔعý³ÌÖÐÖ´Ðв¢³õʼ»¯Sky.info
13
*/
14
15
timeInfo: function()
16
{
17
var _year = new Date().getFullYear();
18
return _year;
19
}(),
20
21
/*
22
* ×÷ÓÃÈý£¬º¯Êý¹ÜÀí£¬ÈÃÄãµÄº¯Êý¿´ÆðÀ´²»ÔÙÄÇôɢÂÒ
23
*/
24
25
sayHello: function()
26
{
27
alert("hello,world!");
28
}
29
30
}
31
32
//ËùÓÐÄÚ²¿ÐÅϢͨ¹ýSkyÕâ¸ö±äÁ¿½øÐзÃÎÊ£»
33
34
alert(Sky.timeInfo);
Ïà¹ØÎĵµ£º
ÓÃÁ˺ܾÃJavaScript£¬¶Ô¡¾this¡¿µÄÈÏʶֻ¾ÖÏÞÓÚÒÔÍùµÄƾ¾Ñé¶øÒÑ£¬²»¹ý½ñÌì·¢ÏÖÁ˺ö«Î÷“http://www.quirksmode.org/js/associative.html”£¬ÏêϸÃèÊöÁËÈçºÎʹÓá¾this¡¿¹Ø¼ü×Ö£¬ÔÚÕâÀïÎҾͼò¶ÌµÄ˵һÏÂÖص㣬Èç¹ûÓÐÒÉÎÊ¿ÉÒÔÖ±½Ó²Î¿¼ÔÎÄ¡£
ÔÚѧϰ¹ýÓÐthisµÄ±à³ÌÓïÑÔÖУ¬thisÒ»°ã¶¼ÊÇÖ¸Ïòµ±Ç°ÊµÀý¶ÔÏóµÄ£¬¶ÔÓ ......
¾³£ÔÚie6ϳöÏÖjavascriptÒ³ÃæÌøתºÍ±íµ¥Ìá½»ÎÊÌ⣬ie6ÏÂʵÏÖjavascriptÒ³ÃæÌøתºÍ±íµ¥Ìá½»ÐèÒª½øÐÐÌرð´¦Àí£¬ÐèҪʹÓÃsetTimeout()º¯ÊýÑÓ³ÙʵÏÖ¡£
1£¬¼æÈݸ÷ä¯ÀÀÆ÷µÄJavascriptÒ³ÃæÌøת
setTimeout(function(){
window.location.href = url;
},0);
2£¬¼æÈݸ÷ä¯ÀÀÆ÷µÄJavascript±íµ¥Ìá½»
setTimeout(function ......
1¡¢Ê¹ÓÃPage.ClientScript.RegisterClientScriptBlock
RegisterClientScriptBlock·½·¨¿ÉÒÔ°ÑJavaScriptº¯Êý·ÅÔÚÒ³ÃæµÄ¶¥²¿¡£Ò²¾ÍÊÇ˵£¬¸Ã½Å±¾ÓÃÓÚÔÚä¯ÀÀÆ÷ÖÐÆô¶¯Ò³Ãæ¡£
Code
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object send ......
1.document.formName.item('itemname')µÄÎÊÌâ
˵Ã÷£ºIEÏ¿ÉÒÔʹÓÃdocument.formName.item('itemname')ºÍdocument.formName.elements('elementsName');
FFÏÂÖ»ÄÜʹÓÃdocuement.formName.elements('elementsName');
½â¾ö·½·¨£ºÍ³Ò»Ê¹ÓÃdocuement.formName.elements('elementsName');
2.¼¯ºÏÀà¶ÔÏóÎÊÌâ
˵Ã÷£ºIEÏ¿ÉÒÔʹÓÃ[]ºÍ ......
1. º¯ÊýÔÚÖ´ÐÐÍê return Ö¸Áîºó¾Í»áÍ£Ö¹Ö´ÐдúÂë.
function test(Num1,Num2){
return Num1+Num2;
alert(Num1+Num2); //never outputs
}
2. javascript º¯Êý²»ÄÜÖØÔØ,Ò²¾ÍÊÇ˵¿ÉÒÔÔÚͬһ¸ö×÷ÓÃÓòÖж¨Òå¶à¸öͬÃûº¯Êý,¶ø×îÖÕÖ´ÐеÄÊǺóÒ»¸öº¯Êý.
function test(num){
alert(num+10);
}
function ......