JavascriptÖеÄÀûÓÃÔÐÎÁ´ºÍ¶ÔÏóð³ä´´½¨Àà
¿´µ½Ò»¸öÔø¾¸ã¹ýwebµÄÈ˵ÄblogÖÐ˵µ½Èç¹ûѧJavascript²»¶®ÔÐÎÁ´£¬¾ÍÌ«Òź¶ÁË£¬ËùÒÔµ±×Ô¼º¿´¡¶javascript¸ß¼¶³ÌÐòÉè¼Æ¡·Ê±¾ÍÁôÒâÁËһϣ¬ËµÊµ»°£¬ÏÂÃæµÄ´úÂëºÜ¼òµ¥£¬µ«ÊDz»ÊǺܶ®ËùνµÄÔÐÎÁ´ºÍ¶ÔÏóð³äÖ®ÀàµÄ¶«Î÷ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type" />
<title>¼Ì³Ð»úÖƵÄʵÏÖ--ʵÀý</title>
<script type="text/javascript">
function Polygon(iSides){
this.sides=iSides;
}
Polygon.prototype.getArea=function(){
return 0;
};
function Triangle(iBase,iHeight){
Polygon.call(this,3);
this.base=iBase;//ÉèÖûù±¾µÄ±ßÊý
this.height=iHeight;
}
Triangle.prototype=new Polygon();
Triangle.prototype.getArea=function(){
return 0.5*this.base*this.height;
};
function Rectangle(iWidth,iHeight){
Polygon.call(this,4);
this.width=iWidth;
this.height=iHeight;
}
Rectangle.prototype=new Polygon();
Rectangle.prototype.getArea=function(){
return this.width*this.height;
};
var triangle=new Triangle(12,4);
var rectangle=new Rectangle(22,10);
alert("Èý½ÇÐεıß
Ïà¹ØÎĵµ£º
JavaScriptÖд´½¨¶ÔÏóµÄ·½·¨ÈçÏ£º
Ò»¡¢´´½¨¼òµ¥¶ÔÏó£º
×î¼òµ¥µÄ´´½¨¶ÔÏóµÄ·½·¨¾ÍÊÇÓÃÒ»¸öеÄObject£¬È»ºóÏòÆäÖÐÌí¼ÓÄÚÈÝ£º
ÏÖÔÚµ÷ÓÃmyObject.say(),½«µ¯³ö’gao’µÄ¾¯¸æ¿ò¡£
var myObject = new Object();
myObject.name = ‘gao’;
myObject.say = function(){
alert ......
Try...Catch Óï¾ä
try...catch ¿ÉÒÔ²âÊÔ´úÂëÖеĴíÎó¡£try ²¿·Ö°üº¬ÐèÒªÔËÐеĴúÂ룬¶ø catch ²¿·Ö°üº¬´íÎó·¢ÉúʱÔËÐеĴúÂë¡£
Óï·¨£º
try
{
//ÔÚ´ËÔËÐдúÂë
}
catch(err)
{
//ÔÚ´Ë´¦Àí´íÎó
}
×¢Ò⣺
try...catch ʹÓÃСд×Öĸ¡£´óд×Öĸ»á³ö´í¡£
ʵÀý 1
ÏÂÃæµÄÀý×ÓÔ±¾ÓÃÔÚÓû§µã»÷°´Å¥Ê±ÏÔʾ " ......
JavaScript µÄ³É¹¦ÈÃÈ˽ò½òÀÖµÀ£¬Îª Web ÍøÒ³±àд JavaScript ´úÂëÒѾÊÇËùÓÐ Web Éè¼ÆʦµÄ»ù±¾¹¦£¬ÕâÃÅÓÐȤµÄÓïÑÔÔ̲Ø×ÅÐí¶à²»ÎªÈËÊìÖªµÄ¶«Î÷£¬¼´Ê¹¶àÄêµÄ JavaScript ³ÌÐòÔ±£¬Ò²Î´ÄÜÍêÈ«³Ô͸¡£±¾ÎÄ´Ó7¸ö·½Ãæ½²Êö JavaScript ÖÐÄÇЩÄã²»ºÜÊìÖªµ«·Ç³£ÊµÓõļ¼ÇÉ¡£
¼òÂÔÓï¾ä
JavaScript ¿ÉÒÔʹÓüòÂÔÓï¾ä¿ìËÙ´´½¨¶ÔÏóºÍÊý× ......
¶ÔÏó³õʼ»¯·½Ê½(Ò²½Ðjson¶ÔÏó´´½¨·½Ê½)
<script type="text/javascript">
var User = {
name:"centerqi",
age:25,
toString:function()
  ......
/* ·½·¨:Array.remove(dx)
* ¹¦ÄÜ:ɾ³ýÊý×éÔªËØ.
* ²ÎÊý:dxɾ³ýÔªËصÄϱê.
* ·µ»Ø:ÔÚÔÊý×éÉÏÐÞ¸ÄÊý×é
*/
//¾³£ÓõÄÊÇͨ¹ý±éÀú,Öع¹Êý×é.
Array.prototype.remove=function(dx)
{
if(isNaN(dx)||dx>this.length){return false;}
for(var i=0,n=0;i<this.length;i++)
{
......