JavaScriptÖж¨ÒåÀà»ò¶ÔÏó
1£¬¶ÔÏóµÄ¹¹³É
¶ÔÏóÓÐÌØÐÔ¹¹³É(attribute)£¬¿ÉÒÔÊÇÔʼֵ£¬Ò²¿ÉÒÔÊÇÒýÓÃÖµ¡£Èç¹ûÌØÐÔ´æ·ÅµÄÊǺ¯Êý£¬Ëü½«±»¿´×ö¶ÔÏóµÄ·½·¨£¨method£©£¬·ñÔò¸ÃÌØÐÔ±»¿´×öÊôÐÔ£¨property£©¡£
2£¬¶¨ÒåÀà»ò¶ÔÏó
£¨1£©¹¤³§·½Ê½
Code
function createCar(sColor,iDoors) {
var oTempCar = new Object;
oTempCar.color = sColor;
oTempCar.doors = iDoors;
oTempCar.showColor = function() {
alert(this.color);
};
return oTempCar;
}
var oCar1 = createCar("red",4);
var oCar2 = createCar("blue", 3);
oCar1.showColor(); //Output "red"
oCar2.showColor(); //Output "blue"
ȱµã£º
ÿ´Îµ÷Óú¯ÊýcreateCar()ʱ£¬¶¼Òª´´½¨Ðº¯ÊýshowColor()£¬Òâζ×Åÿ¸ö¶ÔÏó¶¼ÓÐ×Ô¼ºµÄshowColor()°æ±¾¡£
¸Ä½ø£º
function showColor() {
alert(this.color);
}
function createCar(sColor,iDoors) {
var oTempCar = new Object;
oTempCar.color = sColor;
oTempCar.doors = iDoors;
oTempCar.showColor = showColor;
return oTempCar;
}
var oCar1 
Ïà¹ØÎĵµ£º
¡¾PB.NET±à³ÌϵÁÐ6¡¿ÀûÓÃJavaScript½øÐпͻ§¶Ë±à³Ì
ÆÕͨWEB³ÌÐòÊÇÓÉä¯ÀÀÆ÷·¢³öÇëÇ󣬷þÎñÆ÷ÒÔHTMLÐÎʽ·µ»Ø½á¹û¡£Ò»°ãÇé¿öÏÂÎÒÃÇÔÚPBµÄʼþÀï±àдµÄÈκζԿͻ§¶ËʼþµÄÏìÓ¦´úÂ붼»á²úÉúÒ»´ÎÓë·þÎñÆ÷µÄ½»»¥¹ý³Ì£ºµ±Ò»¸ö¿Í»§¶Ëʼþ±»´¥·¢Ê±£¬JavaScriptÖÐÓÐÒ»¸ö¶ÔÓ¦µÄʼþÈ¥Ïò·þÎñÆ÷·¢ÆðÇëÇ󣬷þÎñÆ÷¶Ë»áµ÷ÓöÔӦʼþµÄ´úÂë² ......
javascript ÉèÖÃcookie×¢ÒâÊÂÏî
javascript ÉèÖÃcookie×¢ÒâÊÂÏî
ÔÚJavascript ÖУ¬cookie ¿ÉÒÔͨ¹ý document.cookie½øÐÐÉèÖ㬵±ÉèÖöà¸öcookieʱä¯ÀÀÆ÷»á×Ô¶¯°Ñ
ËüÃÇÓ÷ֺŸô¿ª¡£ÈçÏ£º
document.cookie = 'cookie1';
document.cookie ='cookie2';
alert (document.cookie) ;//Êä³ö cookie1 ; cookie2
µ«ÊÇÈç¹û°ÑµÚ ......
//¹Ø±Õ,¸¸´°¿Úµ¯³ö¶Ô»°¿ò,×Ó´°¿ÚÖ±½Ó¹Ø±Õ
this.Response.Write("<script language=javascript>window.close();");
//¹Ø±Õ,¸¸´°¿ÚºÍ×Ó´°¿Ú¶¼²»µ¯³ö¶Ô»°¿ò,Ö±½Ó¹Ø±Õ
this.Response.Write("");
this.Response.Write("{top.opener =null;top.close();}");
this.Response.Write("");
//µ¯³ö´°¿Úˢе±Ç°Ò³Ãæwidth=20 ......
<script language="JavaScript" type="text/JavaScript">
<!--
function displayScreenSize()
{
var bodyWidth ......