Ñо¿Ò»ÏÂJavaScriptµÄº¯Êý»Øµ÷»úÖÆ
Ñо¿Ò»ÏÂJavaScriptµÄº¯Êý»Øµ÷»úÖÆ
1¡¢±³¾°
JavascriptÖеĻص÷º¯Êý£¬ÏàÐÅ´ó¼Ò¶¼²»Ä°Éú£¬×îÃ÷ÏÔµÄÀý×ÓÊÇ×öAjaxÇëÇóʱ£¬ÌṩµÄ»Øµ÷º¯Êý£¬
ʵ¼ÊÉÏDOM½ÚµãµÄʼþ´¦Àí·½·¨£¨onclick,ondblclickµÈ£©Ò²Êǻص÷º¯Êý¡£
ÔÚʹÓÃDWRµÄʱºò£¬»Øµ÷º¯Êý¿ÉÒÔ×÷ΪµÚÒ»¸ö»òÕß×îºóÒ»¸ö²ÎÊý³öÏÖ£¬È磺
function callBack(result){
}
myDwrService.doSomething(param1,param2,callBack);//DWRµÄÍƼö·½Ê½
//»òÕß
myDwrService.doSomething(callBack,param1,param2);
2¡¢ÎÊÌâÃèÊö
×î½üÔÚʹÓÃDojo+DwrµÄʱºò£¬Åöµ½Ò»¸öÎÊÌ⣺
Èç¹û»Øµ÷º¯ÊýÊÇÊôÓÚij¸ö¶ÔÏ󣨼ÇΪobj1£©µÄ·½·¨£¬µÈµ½DWRÖ´Ðиûص÷º¯ÊýµÄʱºò£¬
ÉÏÏÂÎÄÈ´²»ÊÇobj1¡£
±íÏÖµÄÏÖÏó¾ÍÊÇÔڻص÷º¯ÊýÖзÃÎÊobj1µÄÈκÎÊôÐÔ¶¼ÊÇundefined¡£
°æ±¾£ºDojo1.3.1ºÍdwr2
3¡¢Ä£ÄâÎÊÌâµÄ´úÂë
ÏÂÃæµÄ²âÊÔ´úÂë¿ÉÒÔÄ£ÄâÕâ¸öÎÊÌ⣺
<html>
<head>
<script>
var context="È«¾Ö";
var testObj={
context:"³õʼ",
callback:function (str){//»Øµ÷º¯Êý
alert("callback:ÎÒËù´¦µÄÉÏÏÂÎÄÖУ¬context="+this.context+"£¬ÎÒ±»»Øµ÷µÄ·½Ê½£º"+str);
}
};//´´½¨Ò»¸ö¶ÔÏó£¬×÷Ϊ²âÊԻص÷º¯ÊýµÄÉÏÏÂÎÄ
testObj.context="ÒÑÉèÖÃ";
function testCall(){
callMethod(testObj.callback);
callObjMethod(testObj,testObj.callback);
}
function callObjMethod(obj,method){
method.call(obj,"Ö¸¶¨ÏÔʽ¶ÔÏóÉÏÏÂÎĻص÷");
}
functio
Ïà¹ØÎĵµ£º
×Û¹ÛÒ»¸öϵͳµÄ·¢Õ¹£¬ÎÞ·ÇÊÇ·¢ÏÖÒ»¸öÎÊÌâ¾Í°ÑËü¶ÀÁ¢³öÀ´½â¾öµô£¬Òò´ËËüµÄËùÓÐÄ£¿é£¨»òÕß·ÖÖ§£©ÆäʵÕë¶Ô¶ÀÁ¢µÄÎÊÌ⣬ÕâÑùÎÒÃǶÔÕâЩÎÊÌâÈôÓÐʲô¸üºÃµÄ½â¾ö·½·¨£¬Ìæ»»ÏàÓ¦µÄÄ£¿é±ãÊÇ£¬Òª²»´úÂë»ìÔÓÔÚÒ»Æðû·¨¿´ÁË¡£ÉÏÒ»²¿·Ö¾ÍÌáµ½ÁË£¬attachEventµÄʼþÁжӳöÁËЩÎÊÌ⣬ÎÒÃÇÒªÊÖ¶¯¹¹½¨ÁжÓÁË¡£ËùνÁжӾÍÊÇÓÐÏÈÓкóµÄÎÊÌâ£¬Ò ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy=& ......
Try...Catch Óï¾ä
try...catch ¿ÉÒÔ²âÊÔ´úÂëÖеĴíÎó¡£try ²¿·Ö°üº¬ÐèÒªÔËÐеĴúÂ룬¶ø catch ²¿·Ö°üº¬´íÎó·¢ÉúʱÔËÐеĴúÂë¡£
Óï·¨£º
try
{
//ÔÚ´ËÔËÐдúÂë
}
catch(err)
{
//ÔÚ´Ë´¦Àí´íÎó
}
×¢Ò⣺
try...catch ʹÓÃСд×Öĸ¡£´óд×Öĸ»á³ö´í¡£
ʵÀý 1
ÏÂÃæµÄÀý×ÓÔ±¾ÓÃÔÚÓû§µã»÷°´Å¥Ê±ÏÔʾ " ......
ÉÏ»Ø˵µ½£¬²Ù×÷Object Array
Æäʵ»¹¿ÉÒÔÕâÑù²Ù×÷£º
var Room = [
{
ID: 'bot',
name: 'test' ......