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("Èý½ÇÐεıß
Ïà¹ØÎĵµ£º
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
ÏÂÃæµÄÀý×ÓÔ±¾ÓÃÔÚÓû§µã»÷°´Å¥Ê±ÏÔʾ " ......
< a href =
"#"
onClick =
"javascript:window.external.AddFavorite(document.URL,document.title);return
false"
rel=
"sidebar"
> Êղر¾Ò³ </ a >
È¡µÃµ±Ç°Ò³µÄURL: document.URL
È¡µÃµ±Ç°Ò³µÄtitle: document.title
ʵÏÖÔÚFirefoxÖГÊÕ
²Ø±¾Ò ......
¶ÔÏó³õʼ»¯·½Ê½(Ò²½Ðjson¶ÔÏó´´½¨·½Ê½)
<script type="text/javascript">
var User = {
name:"centerqi",
age:25,
toString:function()
  ......