Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÏòAsp.netÒ³ÃæÌí¼Ójavascript½Å±¾

1¡¢Ê¹ÓÃPage.ClientScript.RegisterClientScriptBlock
RegisterClientScriptBlock·½·¨¿ÉÒÔ°ÑJavaScriptº¯Êý·ÅÔÚÒ³ÃæµÄ¶¥²¿¡£Ò²¾ÍÊÇ˵£¬¸Ã½Å±¾ÓÃÓÚÔÚä¯ÀÀÆ÷ÖÐÆô¶¯Ò³Ãæ¡£
Code
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender£¬EventArgs e)
{
string myScript = @"function AlertHello() { alert('Hello ASP.NET'); }";
Page.ClientScript.RegisterClientScriptBlock(this.GetType()£¬
"MyScript"£¬myScript£¬true);
}
</script>
ÔÚÕâ¸öÀý×ÓÖУ¬°ÑJavaScriptº¯ÊýAlertHello()´´½¨ÎªÒ»¸ö×Ö·û´®myScript¡£È»ºóʹÓÃPage. ClientScript.RegisterClientScriptBlock·½·¨±àд·ÅÔÚÒ³ÃæÉϵĽű¾¡£RegisterClientScriptBlock·½·¨µÄÁ½¸ö¹¹½¨·½Ê½ÈçÏ£º
¡ñ RegisterClientScriptBlock (type£¬key£¬script)
¡ñ RegisterClientScriptBlock (type£¬key£¬script£¬script tag specification)
4.4.2 ʹÓÃPage.ClientScript.RegisterStartupScript
RegisterStartupScript·½·¨ÓëRegisterClientScriptBlock·½·¨µÄÇø±ð²»´ó¡£×î´óµÄÇø±ðÊÇRegisterStartupScript°Ñ½Å±¾·ÅÔÚASP.NETÒ³ÃæµÄµ×²¿£¬¶ø²»ÊǶ¥²¿¡£Êµ¼ÊÉÏ£¬RegisterStartup Script·½·¨ÉõÖÁʹÓÃÓëRegisterClientScriptBlock·½·¨ÏàͬµÄ¹¹Ô캯Êý£º
¡ñ RegisterStartupScript (type£¬key£¬script)
¡ñ RegisterStartupScript (type£¬key£¬script£¬script tag specification)
ÄÇô£¬ÔÚÒ³ÃæÉÏ×¢²á½Å±¾µÄ¹ý³ÌÓÐʲôÇø±ð£¿Êµ¼ÊÉÏÇø±ðºÜ´ó£¡
Èç¹ûÔÚÒ³ÃæÉÏÓÐһЩ´¦Àí¿Ø¼þµÄJavaScript£¬ÔÚ´ó¶àÊýÇé¿öÏÂӦʹÓÃRegisterStartupScript·½·¨£¬¶ø²»ÊÇRegisterClientScriptBlock·½·¨¡£
¾ÍÊÇ£¬²éÕÒ¡¢µ÷ÓÃÒ³Ãæ¿Ø¼þµÄʱºò£¬¾ÍʹÓà Page.ClientScript.RegisterStartupScript
4.4.3ʹÓÃPage.ClientScript.RegisterClientScriptInclude
×îºóÒ»¸ö·½·¨ÊÇRegisterClientScriptInclude¡£Ðí¶à¿ª·¢ÈËÔ±¶¼°ÑJavaScript·ÅÔÚ.jsÎļþÖУ¬ÕâÊÇ×îºÃµÄ·½Ê½£¬ÒòΪºÜÈÝÒװѶÔJavaScriptµÄÐÞ¸ÄÓ¦ÓÃÓÚÕû¸öÓ¦ÓóÌÐò¡£Ê¹ÓÃRegisterClientScriptInclude·½·¨¿ÉÒÔÔÚASP.NETÒ³ÃæÉÏ×¢²á½Å±¾Îļþ£¬ÈçÏÂËùʾ¡£
string myScript = "myJavaScriptCode.js"
Page.ClientScript.RegisterClientScriptInclude("myKey"£¬myScript);
 
Óï·¨C#
public void RegisterClientScriptBlock ( Type type,


Ïà¹ØÎĵµ£º

½â¾öie6ÏÂJavascriptÒ³ÃæÌøתºÍ±íµ¥Ìá½»ÎÊÌâ

¾­³£ÔÚie6ϳöÏÖjavascriptÒ³ÃæÌøתºÍ±íµ¥Ìá½»ÎÊÌ⣬ie6ÏÂʵÏÖjavascriptÒ³ÃæÌøתºÍ±íµ¥Ìá½»ÐèÒª½øÐÐÌرð´¦Àí£¬ÐèҪʹÓÃsetTimeout()º¯ÊýÑÓ³ÙʵÏÖ¡£
1£¬¼æÈݸ÷ä¯ÀÀÆ÷µÄJavascriptÒ³ÃæÌøת
setTimeout(function(){
window.location.href = url;
},0);
2£¬¼æÈݸ÷ä¯ÀÀÆ÷µÄJavascript±íµ¥Ìá½»
setTimeout(function ......

JavaScriptÖÐArray£¨Êý×飩µÄÊôÐԺͷ½·¨

Êý×éÓÐËÄÖÖ¶¨ÒåµÄ·½Ê½
ʹÓù¹Ô캯Êý£º
var a = new Array();
var b = new Array(8);
var c =
new Array("first", "second", "third");
»òÕßÊý×éÖ±½ÓÁ¿£º
var d = ["first",
"second", "third"];
ÊôÐÔ
ArrayÖ»ÓÐÒ»¸öÊôÐÔ£¬¾ÍÊÇlength£¬length±íʾµ ......

.netºÍjavascript ÕýÔò±í´ïʽµÄ¶Ô±È

javascript
ÉùÃ÷:1.var reg=new Regex("^±í´ïʽ$","²ÎÊý") 2.ÄäÃû(JSonµÄд·¨) /±í´ïʽ/²ÎÊý,Èç:/±í´ïʽ/gi
×¢Òâ:¶þÖÖÉùÃ÷ÊǵÈЧµÄ,ÒÔÏÂʹÓÃregµÄλÖÃ,Ò²¿ÉÓÃ"ÄäÃû"Ìæ»».
Ìæ»»:
var str="×Ö·û´®";
var str2= str.replcace(reg»òÄäÃû,"Ìæ»»³ÉµÄ×Ö·û´®")
ÕÒ³öËùÓаüº¬µÄ:
var str="×Ö·û´®";
var arr=str.match(r ......

javascript²Ù×÷¸´Ñ¡¿òº¯Êý

javascript²Ù×÷¸´Ñ¡¿òº¯Êý
function CheckAll(form) {//È«Ñ¡
for (var i=0;i    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
   }
}
function checkSelect()//ÅжÏÊÇ·ñÓÐÑ¡ ......

javascript¶ÔÏóÖ®——ÄÚÖöÔÏó¡°Math¡±

javascript¶ÔÏóÖ®——ÄÚÖöÔÏó“Math”
Math¶ÔÏóµÄһЩ·½·¨ÄÜʵÏÖÎÒÃǿα¾ÉϵÄijЩÊýѧ¼ÆË㣬±È½Ï³£Óõķ½·¨ÓÐÈçϼ¸¸ö£º
Ò»¡¢Math.min()ºÍMath.max()£¬·Ö±ð·µ»Ø²ÎÊýÖеÄ×îСºÍ×î´óÖµ
¡¡¡¡Àý£º
¡¡¡¡alert(Math.min(1,2,3))¡¡¡¡//Êä³ö “1”
¡¡¡¡alert(Math.max(1,2,3))¡¡¡¡//Êä³ö &ldq ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ