??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品无码mⅴ在线观看,亚洲熟女一区二区三区,亚洲精品精华液一区二区 http://m.tkk7.com/jaunt/category/20890.html站在巨h的肩?lt;br> Flying in the world of Javazh-cnWed, 10 Oct 2007 22:21:24 GMTWed, 10 Oct 2007 22:21:24 GMT60Javascript 如何实现对象的拖动?http://m.tkk7.com/jaunt/archive/2007/10/10/151841.htmlJauntJauntWed, 10 Oct 2007 09:51:00 GMThttp://m.tkk7.com/jaunt/archive/2007/10/10/151841.htmlhttp://m.tkk7.com/jaunt/comments/151841.htmlhttp://m.tkk7.com/jaunt/archive/2007/10/10/151841.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/151841.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/151841.html解决思\
    q个效果q不常见,通常用于游戏或个人站点中。因为拖x靠鼠标来操作的,
所以对鼠标的位|的捕获是问题的重点Q然后才是根据鼠标的位置讄层的位置?

具体步骤Q?
1.在对??上按下鼠标时Q先捕获到需要拖曳的对象Q然后获取或讄该对象的相关属性?

obj=event.srcElement
obj.setCapture()
z=obj.style.zIndex
obj.style.zIndex=100
x=event.offsetX
y=event.offsetY
down=true

2.开始拖xQ捕获鼠标当前位|,q根据该数D|被拖曳对象的位|?

obj.style.posLeft=document.body.scrollLeft+event.x-x
obj.style.posTop=document.body.scrollTop+event.y-y

3.拖曳完松开鼠标后,重设标志 down Q还原对象的 z-indexq攑֯它的鼠标捕捉?

down=false 
obj.style.zIndex=z 
obj.releaseCapture()

4.完整代码?

<script>
var x,y,z,down=false,obj   
function init(){
obj=event.srcElement     //事g触发对象
obj.setCapture()            //讄属于当前对象的鼠标捕?
z=obj.style.zIndex          //获取对象的z轴坐标?
//讄对象的z轴坐标gؓ100Q确保当前层昄在最前面
obj.style.zIndex=100
x=event.offsetX   //获取鼠标指针位置相对于触发事件的对象的X坐标
y=event.offsetY   //获取鼠标指针位置相对于触发事件的对象的Y坐标
down=true         //布尔|判断鼠标是否已按下,true为按下,false为未按下
}

function moveit(){
//判断鼠标已被按下且onmouseover和onmousedown事g发生在同一对象?
 if(down&&event.srcElement==obj){
   with(obj.style){
/*讄对象的X坐标gؓ文档在X轴方向上的滚动距d上当前鼠标指针相当于文档对象的X坐标值减

鼠标按下时指针位|相对于触发事g的对象的X坐标*/

        posLeft=document.body.scrollLeft+event.x-x
/*讄对象的Y坐标gؓ文档在Y轴方向上的滚动距d上当前鼠标指针相当于文档对象的Y坐标值减

鼠标按下时指针位|相对于触发事g的对象的Y坐标*/
        posTop=document.body.scrollTop+event.y-y
   }
 }
}

function stopdrag(){
//onmouseup事g触发时说明鼠标已l松开Q所以设|down变量gؓfalse
down=false 
obj.style.zIndex=z       //q原对象的Z轴坐标?
obj.releaseCapture() //释放当前对象的鼠标捕?
}
</script>

<div onmousedown=init() onmousemove=moveit()   onmouseup=stopdrag()
style="position:absolute;left:20;top:190;width:100;height:150;border:1px
solid #000000;z-index:1;background:#eeeeee">Layer 1</div>
<div onmousedown=init() onmousemove=moveit() onmouseup=stopdrag()
style="position:absolute;left:60;top:10;width:100;height:150;border:1px
solid #000000;z-index:2;background:#eeeeee">Layer 2</div>
<div onmousedown=init() onmousemove=moveit() onmouseup=stopdrag()
style="position:absolute;left:100;top:90;width:100;height:150;border:1px
solid #000000;z-index:3;background:#eeeeee">Layer 3</div>

注意Q只?nbsp;CSS ?nbsp;position 属性gؓ absolute 的对象才能进行拖动操作?
提示Q如果需要将拖曳lg化,可以参考第二部分HTC一节?
技巧:可以?nbsp;init() 函数中加一?nbsp;event.cancelBubble=true Q以取消在该对象上的事g冒?
试一试:读者可以试着实现Ud其他对象Q例如移动一个图片或文本框?
特别提示
在拖曛_象前必须保该对象的为绝对定位的Q把上面的完整代码保存就可以看到效果了,
在实际就用时务必在对象上加上 onmousedown、onmousemove和onmouseup三个事gq触发相应函数?/font>

代码q行效果如图 3.8 所C?

?nbsp;3.8 可拖动的?

特别说明


本例需要掌握的技巧比较多Q捕捉鼠标,获取鼠标位置(相当于对?Q释N标捕捉,文档的滚动距还有with 语句?
1.       setCapture() 讄属于当前文档的对象的鼠标捕捉?
2.       event.offsetX 讄或获取鼠标指针位|相对于触发事g的对象的 x 坐标?
3.       event.offsetY 讄或获取鼠标指针位|相对于触发事g的对象的 y 坐标?
4.       releaseCapture() 释放当前文档中对象的鼠标捕捉?
5.       scrollLeft 讄或获取位于对象左边界和窗口中目前可见内容的最左端之间的距R?
6.       scrollTop 讄或获取位于对象最端和窗口中可见内容的最端之间的距R?
7.       with Z个或多个语句讑֮默认对象?/font>


以下q个Ҏ做出来的比较好看Qƈ增加了层的几个功?

<html>
<head>
<title>_xWin</title>
<style type='text/css'>
<!--
a:visited{text-decoration:none;color:slategray;}
a:hover{text-decoration:underline;color:slategray;}
a:link{text-decoration:none;color:slategray;}
-->
</style>
<script language=JScript>
<!--
//可以打包为js文g;
var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var hover='orange',normal='slategray';//color;
var index=10000;//z-index;
//开始拖?
function startDrag(obj)
{
//锁定标题?
obj.setCapture();
//定义对象;
var win = obj.parentNode;
var sha = win.nextSibling;
//记录鼠标和层位置;
x0 = event.clientX;
y0 = event.clientY;
x1 = parseInt(win.style.left);
y1 = parseInt(win.style.top);
//记录颜色;
normal = obj.style.backgroundColor;
//改变风格;
obj.style.backgroundColor = hover;
win.style.borderColor = hover;
obj.nextSibling.style.color = hover;
sha.style.left = x1 + offx;
sha.style.top = y1 + offy;
moveable = true;
}
//拖动;
function drag(obj)
{
var win = obj.parentNode;
var sha = win.nextSibling;
if(moveable)
{
 win.style.left = x1 + event.clientX - x0;
 win.style.top = y1 + event.clientY - y0;
 sha.style.left = parseInt(win.style.left) + offx;
 sha.style.top = parseInt(win.style.top) + offy;
}
}
//停止拖动;
function stopDrag(obj)
{
var win = obj.parentNode;
var sha = win.nextSibling;
win.style.borderColor = normal;
obj.style.backgroundColor = normal;
obj.nextSibling.style.color = normal;
sha.style.left = obj.parentNode.style.left;
sha.style.top = obj.parentNode.style.top;
//攑ּ标题?
obj.releaseCapture();
moveable = false;
}
//获得焦点;
function getFocus(obj)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
obj.nextSibling.style.zIndex=idx-1;
}
function min(obj)
{
var win = obj.parentNode.parentNode;
var sha = win.nextSibling;
var tit = obj.parentNode;
var msg = tit.nextSibling;
var flg = msg.style.display=="none";
if(flg)
{
 win.style.height = parseInt(msg.style.height) + parseInt(tit.style.height) + 2*2;
 sha.style.height = win.style.height;
 msg.style.display = "block";
 obj.innerHTML = "0";
}
else
{
 win.style.height = parseInt(tit.style.height) + 2*2;
 sha.style.height = win.style.height;
 obj.innerHTML = "2";
 msg.style.display = "none";
}
}
function cls(obj)
{
var win = obj.parentNode.parentNode;
var sha = win.nextSibling;
win.style.visibility = "hidden";
sha.style.visibility = "hidden";
}
//创徏一个对?
function xWin(id,w,h,l,t,tit,msg)
{
index = index+2;
this.id   = id;
this.width  = w;
this.height = h;
this.left  = l;
this.top   = t;
this.zIndex = index;
this.title  = tit;
this.message = msg;
this.obj   = null;
this.bulid  = bulid;
this.bulid();
}
//初始?
function bulid()
{
var str = ""
 + "<div id=xMsg" + this.id + " "
 + "style='"
 + "z-index:" + this.zIndex + ";"
 + "width:" + this.width + ";"
 + "height:" + this.height + ";"
 + "left:" + this.left + ";"
 + "top:" + this.top + ";"
 + "background-color:" + normal + ";"
 + "color:" + normal + ";"
 + "font-size:10px;"
 + "font-family:Verdana;"
 + "position:absolute;"
 + "cursor:default;"
 + "border:2px solid " + normal + ";"
 + "' "
 + "onmousedown='getFocus(this)'>"
  + "<div "
  + "style='"
  + "background-color:" + normal + ";"
  + "width:" + (this.width-2*2) + ";"
  + "height:20;"
  + "color:white;"
  + "' "
  + "onmousedown='startDrag(this)' "
  + "onmouseup='stopDrag(this)' "
  + "onmousemove='drag(this)' "
  + ">"
  + "<span style='width:" + (this.width-2*12-4) + ";padding-left:3px;'>" + this.title + "</span>"
  + "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='min(this)'>0</span>"
  + "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='cls(this)'>r</span>"
  + "</div>"
  + "<div style='"
  + "width:100%;"
  + "height:" + (this.height-20-4) + ";"
  + "background-color:white;"
  + "line-height:14px;"
  + "word-break:break-all;"
  + "padding:3px;"
  + "'>" + this.message + "</div>"
 + "</div>"
 + "<div style='"
 + "width:" + this.width + ";"
 + "height:" + this.height + ";"
 + "top:" + this.top + ";"
 + "left:" + this.left + ";"
 + "z-index:" + (this.zIndex-1) + ";"
 + "position:absolute;"
 + "background-color:black;"
 + "filter:alpha(opacity=40);"
 + "'>?</div>";
 //alert(str);
document.body.insertAdjacentHTML("beforeEnd",str);
}
//-->
</script>
<script language='JScript'>
<!--
function initialize()
{
var a = new xWin("1",160,200,200,200,"Message","xWin <br> A Cool Pop Div Window<br>Version:1.0<br>2002-8-13");
var b = new xWin("2",240,200,100,100,"Wildwind's Msgbox","Welcome to visited my personal website:<br>
<a href=http://www14.brinkster.com/wildcity target=_blank>http://wildcity.126.com</a>
<br>and u can also sign my guestbook at:<br><a href=http://www14.brinkster.com/wildcity/gbook target=_blank>
http://wildcity.126.com/gbook</a><br><br>thx!!! =)...");
var c = new xWin("3",200,160,250,50,"Copyright","Copyright by <a href='mailto:wildwind_zz@21cn.com'>Wildwind</a>!");
}
window.onload = initialize;
//-->
</script>
</head>
<body onselectstart='return false' oncontextmenu='return false'>
</body>
</html>

url:
http://100000.myabc.cn/home/Blog/view/23902.htm

Jaunt 2007-10-10 17:51 发表评论
]]>
对google个性主늚拖拽效果的js的完整注?/title><link>http://m.tkk7.com/jaunt/archive/2007/10/10/151836.html</link><dc:creator>Jaunt</dc:creator><author>Jaunt</author><pubDate>Wed, 10 Oct 2007 09:43:00 GMT</pubDate><guid>http://m.tkk7.com/jaunt/archive/2007/10/10/151836.html</guid><wfw:comment>http://m.tkk7.com/jaunt/comments/151836.html</wfw:comment><comments>http://m.tkk7.com/jaunt/archive/2007/10/10/151836.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jaunt/comments/commentRss/151836.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jaunt/services/trackbacks/151836.html</trackback:ping><description><![CDATA[     摘要: // 工具c,使用Util的命名空_方便理 var  Util  =   new  Object(); // 获取http header里面的UserAgentQ浏览器信息 Util.getUserAgent  =  navigator.userAgent; // 是否是Gecko核心的BrowserQ比如Moz...  <a href='http://m.tkk7.com/jaunt/archive/2007/10/10/151836.html'>阅读全文</a><img src ="http://m.tkk7.com/jaunt/aggbug/151836.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jaunt/" target="_blank">Jaunt</a> 2007-10-10 17:43 <a href="http://m.tkk7.com/jaunt/archive/2007/10/10/151836.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>判断Checkbox和Radio的一U方?/title><link>http://m.tkk7.com/jaunt/archive/2007/10/10/151833.html</link><dc:creator>Jaunt</dc:creator><author>Jaunt</author><pubDate>Wed, 10 Oct 2007 09:35:00 GMT</pubDate><guid>http://m.tkk7.com/jaunt/archive/2007/10/10/151833.html</guid><wfw:comment>http://m.tkk7.com/jaunt/comments/151833.html</wfw:comment><comments>http://m.tkk7.com/jaunt/archive/2007/10/10/151833.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jaunt/comments/commentRss/151833.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jaunt/services/trackbacks/151833.html</trackback:ping><description><![CDATA[<html><br /> <head><br /> <title>判断Checkbox和Radio - 51windows.Net</title><br /> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br /> </head><br /> <body><br /> <form method="post" name="myformname1"><br /> <input type="checkbox"  name="checkname1" id="c11" value=""><label for="c11">选择1</label><br /> <input type="checkbox"  name="checkname1" id="c12" value=""><label for="c12">选择2</label><br /> <input type="checkbox"  name="checkname1" id="c13" value=""><label for="c13">选择3</label><br /> <input type="checkbox"  name="checkname1" id="c14" value=""><label for="c14">选择4</label><br /> <br><br><br /> <input type="button" onclick="alert(IsChecked(document.myformname1,'checkname1'))" value="试有没有选择"><br /> <input type="button" onclick="alert(GetCheckedNum(document.myformname1,'checkname1'))" value="试选择几个"><br /> </form><br /> <hr><br /> <form method="post" name="myformname2"><br /> <input type="radio"  name="radioname1" id="r11" value=""><label for="r11">选择1</label><br /> <input type="radio"  name="radioname1" id="r12" value=""><label for="r12">选择2</label><br /> <br><br><br /> <input type="button" onclick="alert(IsChecked(document.myformname2,'radioname1'))" value="试有没有选择"> <input type="reset" value="重置"><br /> </form><br /> <SCRIPT LANGUAGE="JavaScript"><br /> <!--<br /> function IsChecked(oform,checkname){<br />  var len = oform.elements.length;<br />  var i=0;<br />  for( i=0; i<len; i++){<br />   if (oform.elements[i].name==checkname){<br />    if(oform.elements[i].checked){<br />     return true;<br />    }<br />   }<br />  }<br />  return false;<br /> }<br /> function GetCheckedNum(oform,checkname){<br />  var len = oform.elements.length;<br />  var i=0;<br />  var checkn = 0;<br />  for( i=0; i<len; i++){<br />   if (oform.elements[i].name==checkname){<br />    if(oform.elements[i].checked){<br />     checkn++;<br />    }<br />   }<br />  }<br />  return checkn;<br /> }<br /> //--><br /> </SCRIPT><br /> </body><br /> </html> <img src ="http://m.tkk7.com/jaunt/aggbug/151833.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jaunt/" target="_blank">Jaunt</a> 2007-10-10 17:35 <a href="http://m.tkk7.com/jaunt/archive/2007/10/10/151833.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JavaScriptQ等比例~放囄的函?/title><link>http://m.tkk7.com/jaunt/archive/2007/10/10/151831.html</link><dc:creator>Jaunt</dc:creator><author>Jaunt</author><pubDate>Wed, 10 Oct 2007 09:33:00 GMT</pubDate><guid>http://m.tkk7.com/jaunt/archive/2007/10/10/151831.html</guid><wfw:comment>http://m.tkk7.com/jaunt/comments/151831.html</wfw:comment><comments>http://m.tkk7.com/jaunt/archive/2007/10/10/151831.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jaunt/comments/commentRss/151831.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jaunt/services/trackbacks/151831.html</trackback:ping><description><![CDATA[此函?|上资源)h如下功能Q?nbsp;  <p>        1、预先定义好囄昄的标准宽度和高度?br />         2、如果图片的大小过了标准定义,那么{比例压~图片?br />         3、如果图片的大小{于标准定义Q那么按照标准宽度和高度昄囄?br />         4、如果图片的大小于标准定义Q那么不对图片进行Q何压~处理?/p> <br />  <span style="color: #000000;"><</span><span style="color: #000000;">script language</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">JavaScript</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/None.gif" alt="" align="top" height="16" width="11" /></span><span style="color: #000000;"><!--</span><span style="color: #000000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/None.gif" alt="" align="top" height="16" width="11" /></span><span style="color: #008000;">//</span><span style="color: #008000;">囄按比例羃?/span><span style="color: #008000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/None.gif" alt="" align="top" height="16" width="11" /></span><span style="color: #000000;">var flag</span><span style="color: #000000;">=</span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br /> <img id="Codehighlighter1_101_846_Open_Image" style="display: inline;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_101_846_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" alt="" align="top" height="16" width="11" />function DrawImage(ImgD,iwidth,iheight)</span><span style="display: inline;"><span style="color: #000000;">{<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />    </span><span style="color: #008000;">//</span><span style="color: #008000;">参数(囄,允许的宽?允许的高?</span><span style="color: #008000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" /></span><span style="color: #000000;">    var image</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Image();<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />    image.src</span><span style="color: #000000;">=</span><span style="color: #000000;">ImgD.src;<br /> <img id="Codehighlighter1_218_844_Open_Image" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_218_844_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top" height="16" width="11" />    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(image.width</span><span style="color: #000000;">></span><span style="color: #000000;">0</span> <span style="color: #000000;">&&</span><span style="color: #000000;"> image.height</span><span style="color: #000000;">></span><span style="color: #000000;">0</span><span style="color: #000000;">)</span><span style="color: #000000;">{<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />    flag<span style="color: #000000;">=</span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br /> <img id="Codehighlighter1_284_550_Open_Image" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_284_550_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top" height="16" width="11" />    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(image.width</span><span style="color: #000000;">/</span><span style="color: #000000;">image.height</span><span style="color: #000000;">>=</span><span style="color: #000000;"> iwidth</span><span style="color: #000000;">/</span><span style="color: #000000;">iheight)</span><span style="color: #000000;">{<br /> <img id="Codehighlighter1_316_410_Open_Image" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_316_410_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top" height="16" width="11" />        <span style="color: #0000ff;">if</span><span style="color: #000000;">(image.width</span><span style="color: #000000;">></span><span style="color: #000000;">iwidth)</span><span style="color: #000000;">{  <br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.width<span style="color: #000000;">=</span><span style="color: #000000;">iwidth;<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.height</span><span style="color: #000000;">=</span><span style="color: #000000;">(image.height</span><span style="color: #000000;">*</span><span style="color: #000000;">iwidth)</span><span style="color: #000000;">/</span><span style="color: #000000;">image.width;<br /> <img id="Codehighlighter1_415_493_Open_Image" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_415_493_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top" height="16" width="11" />        }</span></span><span style="color: #0000ff;">else</span><span style="color: #000000;">{<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.width<span style="color: #000000;">=</span><span style="color: #000000;">image.width;  <br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.height</span><span style="color: #000000;">=</span><span style="color: #000000;">image.height;<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" align="top" height="16" width="11" />        }</span></span><span style="color: #000000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.alt</span><span style="color: #000000;">=</span><span style="color: #000000;">image.width</span><span style="color: #000000;">+</span><span style="color: #000000;">"</span><span style="color: #000000;">×</span><span style="color: #000000;">"</span><span style="color: #000000;">+</span><span style="color: #000000;">image.height;<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" align="top" height="16" width="11" />        }</span></span><span style="color: #000000;"><br /> <img id="Codehighlighter1_560_838_Open_Image" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_560_838_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top" height="16" width="11" />    </span><span style="color: #0000ff;">else</span><span style="color: #000000;">{<br /> <img id="Codehighlighter1_594_698_Open_Image" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_594_698_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top" height="16" width="11" />        <span style="color: #0000ff;">if</span><span style="color: #000000;">(image.height</span><span style="color: #000000;">></span><span style="color: #000000;">iheight)</span><span style="color: #000000;">{  <br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.height<span style="color: #000000;">=</span><span style="color: #000000;">iheight;<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.width</span><span style="color: #000000;">=</span><span style="color: #000000;">(image.width</span><span style="color: #000000;">*</span><span style="color: #000000;">iheight)</span><span style="color: #000000;">/</span><span style="color: #000000;">image.height;        <br /> <img id="Codehighlighter1_703_781_Open_Image" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top" height="16" width="11" /><img id="Codehighlighter1_703_781_Closed_Image" style="display: none;" src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top" height="16" width="11" />        }</span></span><span style="color: #0000ff;">else</span><span style="color: #000000;">{<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.width<span style="color: #000000;">=</span><span style="color: #000000;">image.width;  <br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.height</span><span style="color: #000000;">=</span><span style="color: #000000;">image.height;<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" align="top" height="16" width="11" />        }</span></span><span style="color: #000000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/InBlock.gif" alt="" align="top" height="16" width="11" />        ImgD.alt</span><span style="color: #000000;">=</span><span style="color: #000000;">image.width</span><span style="color: #000000;">+</span><span style="color: #000000;">"</span><span style="color: #000000;">×</span><span style="color: #000000;">"</span><span style="color: #000000;">+</span><span style="color: #000000;">image.height;<br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" align="top" height="16" width="11" />        }</span></span><span style="color: #000000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" align="top" height="16" width="11" />    }</span></span><span style="color: #000000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" alt="" align="top" height="16" width="11" />}</span></span><span style="color: #000000;"> <br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/None.gif" alt="" align="top" height="16" width="11" /></span><span style="color: #008000;">//</span><span style="color: #008000;">--></span><span style="color: #008000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/None.gif" alt="" align="top" height="16" width="11" /></span><span style="color: #000000;"></</span><span style="color: #000000;">script</span><span style="color: #000000;">></span><span style="color: #000000;"><br /> <img src="http://leimin3113591.cnblogs.com/Images/OutliningIndicators/None.gif" alt="" align="top" height="16" width="11" />调用Q?/span><span style="color: #000000;"><</span><span style="color: #000000;">img src</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">images/toplogo.gif</span><span style="color: #000000;">"</span><span style="color: #000000;"> onload</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">DrawImage(this,100,100)</span><span style="color: #000000;">"</span><span style="color: #000000;">></span> <img src ="http://m.tkk7.com/jaunt/aggbug/151831.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jaunt/" target="_blank">Jaunt</a> 2007-10-10 17:33 <a href="http://m.tkk7.com/jaunt/archive/2007/10/10/151831.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>setInterval全面的介l??http://m.tkk7.com/jaunt/archive/2007/10/10/151829.htmlJauntJauntWed, 10 Oct 2007 09:30:00 GMThttp://m.tkk7.com/jaunt/archive/2007/10/10/151829.htmlhttp://m.tkk7.com/jaunt/comments/151829.htmlhttp://m.tkk7.com/jaunt/archive/2007/10/10/151829.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/151829.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/151829.html setInterval(function,interval[,arg1,arg2,......argn])
setInterval(object,methodName,interval[,arg1,arg2,.....argn])
W一U格式是标准动作面板中setInterval函数的默认语法,W二U格式是在专家模式动作中使用的方法?br /> ? 中的参数function是一个函数名或者一个对匿名函数的引用。object参数指定从Object对象z的对象。methodName制定 object参数中要调用的方法。interval制定对function或methodName调用两次之间的时_单位是毫U。后面的arg1{是? 选的参数Q用于制定传递给function或是methodName的参数?br /> setInterval它设|的旉间隔于动画帧速(如每U?0 帧,相当?00毫秒Q,则按照尽可能接近interval的时间间隔调用函数。而且必须使用updateAfterEvent动作来确保以_的频率刷 新屏q。如果interval大于动画帧速,则只用在每次播放头进入某一帧是才调用,以减每ơ刷新屏q的影响?br /> 下面的例子每?U调用一ơ匿名函数?br />
setInterval(function(){trace("每隔1U钟我就会显CZ?)},1000);//q里的function(){}是没有函数名
的函数。成为匿名函敎ͼ后面?000是时间间隔,单位是毫U?br /> 下面的例子ؓ我们展示如何带参数运行?br />
function show1(){
   trace("每隔1U我׃昄一?);
}
function show2(str){
   trace(str);
}
setInterval(show1,1000);
setInterval(show2,2000,"每隔2U我׃昄一?);
上面已经函数的setIntervalҎ介绍了?br /> 下面我们介l对象的setIntervalҎ?br /> 首先Q写一个setInterval在动作中调用对象的方法的例子Q该例子不需要传递参数?br />
myobj=new Object();//创徏一个新的对?br /> myobj.interval=function){
   trace("每隔1U我׃昄一?);
}//创徏对象的方法?br /> setInterval(myobj,"interval",1000);//讑֮旉间隔调用对象的方法?br />
接下来介l如何传递参数。其实道理和函数的传递参数是一L?br />
myobj=new Object();
myobj.interval-function(str){
   trace(str);
}
setInterval(myobj,"interval",2000," 每隔2U我׃昄一?);
注意。要调用为对象定义的ҎӞ必须在专家模式中使用W二U语法格式?br /> q样子的话呢Q我们来作一个动态显C时间的画面。可以用下面的代码实现?br />
setInterval(show,1000);
function show(){
   time=new Date();
   hour=time.getHours();
      minu=time.getMinutes();
      sec=time.get.Seconds();
   datetime=hour+":"+minu+":"+sec;
}//q里的datetime是一个动态文本框的变量名字?br />
q样子呢QsetIntervalq个Ҏ大家应该学的很好了。现在呢Q我们学习clearInterval.
clearInterval动作的作用是清楚对setInterval函数的调用,它的语法格式如下clearInterval(intervalid);intervalid是调用setInterval函数后返回的对象?br /> 下面举一个简单的例子?br /> function show(){
   trace("每隔一U我׃昄一?);
}
var sh;
sh=setInterval(show,1000);
clearInterval(sh);

Jaunt 2007-10-10 17:30 发表评论
]]>
用javascriptq行拖拽http://m.tkk7.com/jaunt/archive/2007/10/10/151828.htmlJauntJauntWed, 10 Oct 2007 09:25:00 GMThttp://m.tkk7.com/jaunt/archive/2007/10/10/151828.htmlhttp://m.tkk7.com/jaunt/comments/151828.htmlhttp://m.tkk7.com/jaunt/archive/2007/10/10/151828.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/151828.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/151828.html

Jaunt 2007-10-10 17:25 发表评论
]]>
[下蝲]JavaScript权威指南(W五?http://m.tkk7.com/jaunt/archive/2007/04/02/108036.htmlJauntJauntMon, 02 Apr 2007 10:40:00 GMThttp://m.tkk7.com/jaunt/archive/2007/04/02/108036.htmlhttp://m.tkk7.com/jaunt/comments/108036.htmlhttp://m.tkk7.com/jaunt/archive/2007/04/02/108036.html#Feedback1http://m.tkk7.com/jaunt/comments/commentRss/108036.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/108036.html

下蝲J:avaScript权威指南(W五?



Jaunt 2007-04-02 18:40 发表评论
]]>
发现一个有用的js事gonpropertychangehttp://m.tkk7.com/jaunt/archive/2007/03/22/105641.htmlJauntJauntThu, 22 Mar 2007 12:52:00 GMThttp://m.tkk7.com/jaunt/archive/2007/03/22/105641.htmlhttp://m.tkk7.com/jaunt/comments/105641.htmlhttp://m.tkk7.com/jaunt/archive/2007/03/22/105641.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/105641.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/105641.html
<textarea cols="100" rows="15" onpropertychange="alert(this.value)"></textarea>


From:http://www.cnitblog.com/yemoo/archive/2006/07/07/13366.html


Jaunt 2007-03-22 20:52 发表评论
]]>
JS中的setTimeout和setInterval的区?/title><link>http://m.tkk7.com/jaunt/archive/2007/03/22/105640.html</link><dc:creator>Jaunt</dc:creator><author>Jaunt</author><pubDate>Thu, 22 Mar 2007 12:46:00 GMT</pubDate><guid>http://m.tkk7.com/jaunt/archive/2007/03/22/105640.html</guid><wfw:comment>http://m.tkk7.com/jaunt/comments/105640.html</wfw:comment><comments>http://m.tkk7.com/jaunt/archive/2007/03/22/105640.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jaunt/comments/commentRss/105640.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jaunt/services/trackbacks/105640.html</trackback:ping><description><![CDATA[setTimeout(Expression,DelayTime),在DelayTimeq后,执行一ơExpression<br />setInterval(expression,delayTime),每个DelayTime,都将执行Expression<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 255);"><!</span><span style="color: rgb(255, 0, 255);">DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">html </span><span style="color: rgb(255, 0, 0);">xmlns</span><span style="color: rgb(0, 0, 255);">="http://www.w3.org/1999/xhtml"</span><span style="color: rgb(255, 0, 0);"> xml:lang</span><span style="color: rgb(0, 0, 255);">="en"</span><span style="color: rgb(255, 0, 0);"> lang</span><span style="color: rgb(0, 0, 255);">="en"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">div </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="a"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">div</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">div </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="b"</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">div</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">script </span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="text/javascript"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);"><br />setTimeout(</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">document.getElementById('a').innerHTML=<br />new Date().getSeconds();</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">,</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">1000</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">);<br />setInterval(</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">document.getElementById('b').innerHTML=<br />new Date().getSeconds();</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">"</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">,</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">1000</span><span style="color: rgb(0, 0, 0); background-color: rgb(245, 245, 245);">);<br />  </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">script</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">></span></div>From:http://www.cnitblog.com/yemoo/archive/2006/06/29/13078.html<br /><img src ="http://m.tkk7.com/jaunt/aggbug/105640.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jaunt/" target="_blank">Jaunt</a> 2007-03-22 20:46 <a href="http://m.tkk7.com/jaunt/archive/2007/03/22/105640.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javascript技巧(收藏Q?/title><link>http://m.tkk7.com/jaunt/archive/2007/03/22/105580.html</link><dc:creator>Jaunt</dc:creator><author>Jaunt</author><pubDate>Thu, 22 Mar 2007 08:07:00 GMT</pubDate><guid>http://m.tkk7.com/jaunt/archive/2007/03/22/105580.html</guid><wfw:comment>http://m.tkk7.com/jaunt/comments/105580.html</wfw:comment><comments>http://m.tkk7.com/jaunt/archive/2007/03/22/105580.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jaunt/comments/commentRss/105580.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jaunt/services/trackbacks/105580.html</trackback:ping><description><![CDATA[     摘要: 事g源对? event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture();  event.srcElement.releaseCapture();  ...  <a href='http://m.tkk7.com/jaunt/archive/2007/03/22/105580.html'>阅读全文</a><img src ="http://m.tkk7.com/jaunt/aggbug/105580.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jaunt/" target="_blank">Jaunt</a> 2007-03-22 16:07 <a href="http://m.tkk7.com/jaunt/archive/2007/03/22/105580.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>自动对select表单列表q行排序Q收藏)http://m.tkk7.com/jaunt/archive/2007/03/22/105576.htmlJauntJauntThu, 22 Mar 2007 07:55:00 GMThttp://m.tkk7.com/jaunt/archive/2007/03/22/105576.htmlhttp://m.tkk7.com/jaunt/comments/105576.htmlhttp://m.tkk7.com/jaunt/archive/2007/03/22/105576.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/105576.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/105576.html自动对select表单列表q行排序

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"<html xmlns="<head>
<title>runcode</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="Sheneyan" />
<script type="text/javascript">
function s(n){
  var o=document.getElementById(n);
  if (!o) return ;
  var t=[],tt=o.options;
  while(tt.length>0){
  t[t.length]=tt[0].text;
  tt.remove(0);
 }
 t.sort();
  for(var i=0,c;c=t[i];i++){
  tt.add(new Option(c));
 }
}
</script>
</head>
<body onload="s('abc')">
<select id="abc">
<option>华硕</option>
<option>.NET </option>
<option>360 安全卫士</option>
<option>ACDSee</option>
<option>Adobe</option>
<option>Firewall</option>
<option>Alcohol 120%</option>
<option>AMD</option>
<option>AnyDVD</option>
<option>Apple</option>
<option>ATi</option>
<option>AutoDesk</option>
<option>|技</option>
<option>BitComet</option>
<option>BitSpirit(比特_)</option>
<option>BlackIce</option>
<option>BlueTooth</option>
<option>Cisco </option>
<option>CloneCD</option>
<option>CloneDVD</option>
<option>CS-半条?lt;/option>
<option>CuteFTP</option>
<option>千千静听</option>
<option>势U技(PC-cillin)</option>
<option>DAEMON Tools</option>
<option>DELL</option>
<option>DirectX</option>
<option>DivX</option>
<option>DreamMail</option>
<option>PowerDVD</option>
<option>Easy CD-DA</option>
<option>瑞星(Rising)</option>
<option>Editplus</option>
<option>EmEditor</option>
<option>eMule</option>
<option>eMule Plus</option>
<option>FeedDemon</option>
<option>FileZilla</option>
<option>FlashFXP</option>
<option>Flashget</option>
<option>foobar2000</option>
<option>Foxit PDF Reader</option>
<option>Foxmail</option>
<option>FreeBSD</option>
<option>FTPRush</option>
<option>Gmail</option>
<option>Google talk</option>
<option>Google</option>
<option>GoogleToolbar</option>
<option>GoSURF</option>
<option>GreenBrowser</option>
<option>HP</option>
<option>HyperSnap-DX</option>
<option>IBM</option>
<option>ICQ</option>
<option>iMac G5</option>
<option>Intel</option>
<option>Internet Explorer</option>
<option>IPB</option>
<option>iTune</option>
<option>腾讯</option>
<option>微Y</option>
<option>木马克星(iparmor)</option>
<option>天网防火?lt;/option>
<option>木马捆绑克星</option>
<option>风云防火墙个人版</option>
<option>卡巴斯基(Kaspersky)</option>
<option>Maxthon 傲游</option>
<option>Media Player Classic</option>
<option>Windows Media Player</option>
<option>Windows Live Messenger</option>
<option>Microsoft AntiSpyware</option>
<option>Microsoft Office</option>
<option>Mozilla FireFox</option>
<option>Mozilla ThunderBird</option>
<option>MySQL</option>
<option>Nero</option>
<option>NetCaptor</option>
<option>Nettransport</option>
<option>nVIDIA nForce</option>
<option>鱼鱼桌面U</option>
<option>Opera</option>
<option>PHP</option>
<option>QQ病毒专杀工具</option>
<option>QuickTime</option>
<option>RealPlayer</option>
<option>skype</option>
<option>SQL Server 2005</option>
<option>stylexp</option>
<option>TheWorld Browser</option>
<option>TuneUp Utilities</option>
<option>UltraEdit</option>
<option>UltraISO</option>
<option>Winamp</option>
<option>Windows OneCare</option>
<option>Windows优化?lt;/option>
<option>Windows优化大师</option>
<option>WinDVD</option>
<option>WinRAR</option>
<option>WinZip</option>
<option>XnView</option>
<option>Zonealarm</option>
<option>Zoom Player</option>
<option>兔子</option>
<option>风雷影音</option>
<option>急速启?HurryRun</option>
</select>
</body>
</html>

主要有以下几ҎȝQ?br />1Qselect控g本n支持字母索引。比如select控g处于焦点中的时候,按B键,option中相应的以B开头的选项׃昄出来?br />
2Q这D代码写的较?q段代码的作用是一一赋值selectI间列表内容赋给另一个数l?br />var t=[],tt=o.options;
  
while (tt.length>0){
    t[t.length]
=tt[0].text;
    tt.remove(
0);
  }

首先定义数组t=[],用于存储原select控g列表内容?br />tt=o.options;dselectI间内容Q以数组形式存储在tt数组中?br />t[t.length]=tt[0].text;q里时一个技巧,因ؓt.lengthL比当前t的最大烦引大1Q所以这样写数组t可以自动增加I间。tt[0].textq里每次都读取第一个内容,然后用tt.remove(0);删除W一内容,直至d完毕?br />
3Q这D代码对新数l内Ҏ字母z讯Q然后写入原selectI间列表?br />t.sort();
  for (var i=0,c;c=t[i];i++){
    tt.add(
new Option(c));
  }


From IndexQ?a >http://www.cnitblog.com/yemoo/archive/2006/06/20/12573.html


Jaunt 2007-03-22 15:55 发表评论
]]>
一个表格特效的JS代码Q收藏)http://m.tkk7.com/jaunt/archive/2007/03/22/105561.htmlJauntJauntThu, 22 Mar 2007 06:58:00 GMThttp://m.tkk7.com/jaunt/archive/2007/03/22/105561.htmlhttp://m.tkk7.com/jaunt/comments/105561.htmlhttp://m.tkk7.com/jaunt/archive/2007/03/22/105561.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/105561.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/105561.html嘿嘿……今天看到很好用的一个js表格效果Q有旉研究下^_^
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>mytable</title>
<script language="JavaScript">
 // src="anole.js"
// about this: javapig修改 源自 忘了?
// Date: 2006-04-29
 
 function anole(
 str_tableid, // table id
  num_header_offset,// 表头行数
  str_odd_color, // 奇数行的颜色
  str_even_color,// 偶数行的颜色
  str_mover_color, // 鼠标l过行的颜色
  str_onclick_color // 选中行的颜色
  )  {

 // 表格ID参数验证
  if(!str_tableid) return alert(str_tableid+"表格不存?);
 var obj_tables=(document.all ? document.all[str_tableid]:document.getElementById(str_tableid));
 if(!obj_tables) return alert("ID?"+str_tableid+")不存在!");

 // 讄个参数的~省?
  var col_config=[];
 col_config.header_offset=(num_header_offset?num_header_offset:0 );
 col_config.odd_color=(str_odd_color?str_odd_color:'#ffffff');
 col_config.even_color=(str_even_color?str_even_color:'#dbeaf5');
 col_config.mover_color=(str_mover_color?str_mover_color:'#6699cc');
 col_config.onclick_color=(str_onclick_color?str_onclick_color:'#4C7DAB');
 // 初始化表|可能多个表格用同一个IDQ?
  if(obj_tables.length)
  for(var i=0;i<obj_tables.length;i++ )
 tt_init_table(obj_tables[i],col_config);
 else
 tt_init_table(obj_tables,col_config);
}
 
 function tt_init_table(obj_table,col_config)  {
 var col_lconfig=[],
 col_trs=obj_table.rows;
 if(!col_trs) return ;
 
 for(var i=col_config.header_offset;i<col_trs.length;i++)  { // i ?表头以下开?
  col_trs[i].config=col_config;
 col_trs[i].lconfig=col_lconfig;
 col_trs[i].set_color=tt_set_color;
 col_trs[i].onmouseover=tt_mover;
 col_trs[i].onmouseout=tt_mout;
 col_trs[i].onmousedown=tt_onclick;
 col_trs[i].order=(i-col_config.header_offset)%2 ;
 col_trs[i].onmouseout();
 }
}
 function tt_set_color(str_color) {
 this.style.backgroundColor=str_color;
}
 
 // 事g操作
 function tt_mover() {
 if(this.lconfig.clicked!=this )
  this.set_color(this.config.mover_color);
}
 function tt_mout() {
 if(this.lconfig.clicked!=this )
  this.set_color(this.order?this.config.odd_color:this.config.even_color);
}
 function tt_onclick()  {
 if( this.lconfig.clicked==this) {
  this.lconfig.clicked=null;
  this.onmouseover();
 }
  else {
  var last_clicked=this.lconfig.clicked;
  this.lconfig.clicked=this ;
  if(last_clicked) last_clicked.onmouseout();
  this.set_color(this.config.onclick_color);
 }
}
 
</script>
</head>

<body>
<table bgcolor="#9933ff" align="center" cellpadding="1" cellspacing="0" width="80%">
 <tr>
 <td>
 <table id="demo" cellpadding="1" cellspacing="1" border="0" width="100%" align="center">
 <tr><th colspan="2" bgcolor="ffffff">HTML document object properties</th></tr>
 <tr><td width="20%">activeElement</td><td>Retrieves the object that has the focus.</td></tr>
 <tr><td>aLinkColor</td><td>Sets or retrieves the color of all links in the document.</td></tr>
 <tr><td>bgColor</td><td>Sets or retrieves the background color behe document object.</td></tr>
 <tr><td>body</td><td>Specifies the beginning and end of the document body.</td></tr>
 <tr><td>contentEditable</td><td>Sets or retrieves whether the userdocument object.</td></tr>
 <tr><td>cookie</td><td>Sets or retrieves the string value of a cookie.</td></tr>
 <tr><td>defaultCharset</td><td>Sets or retrieves the default chara of the document.</td></tr>
 <tr><td>designMode</td><td>Sets or retrieves whether the document can be edited.</td></tr>
 <tr><td>documentElement</td><td>Retrieves a reference to the root node of the document.</td></tr>
 <tr><td>domain</td><td>Sets or retrieves the security domain of the document.</td></tr>
 </table>
 </td>
 </tr>
 </table>
 <script language="JavaScript">
  anole('demo',1,'#ffffff','#ccccff','#ffccff','#cc99ff');
 </script>
</body>
</html>

From IndexQ?a >http://www.cnitblog.com/yemoo/archive/2006/06/16/12362.html



Jaunt 2007-03-22 14:58 发表评论
]]>
讑֮属性rel为external与internal的不?/title><link>http://m.tkk7.com/jaunt/archive/2007/03/22/105558.html</link><dc:creator>Jaunt</dc:creator><author>Jaunt</author><pubDate>Thu, 22 Mar 2007 06:47:00 GMT</pubDate><guid>http://m.tkk7.com/jaunt/archive/2007/03/22/105558.html</guid><wfw:comment>http://m.tkk7.com/jaunt/comments/105558.html</wfw:comment><comments>http://m.tkk7.com/jaunt/archive/2007/03/22/105558.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jaunt/comments/commentRss/105558.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jaunt/services/trackbacks/105558.html</trackback:ping><description><![CDATA[ <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"> <span style="COLOR: rgb(0,0,255)"> <font color="#000000">在网上看了一下js代码感觉有点用,p{q来Q也是俺的一点小l习?/font> <br /> <br /><!</span> <span style="COLOR: rgb(255,0,255)">DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">html </span> <span style="COLOR: rgb(255,0,0)">xmlns</span> <span style="COLOR: rgb(0,0,255)">="http://www.w3.org/1999/xhtml"</span> <span style="COLOR: rgb(255,0,0)"> xml:lang</span> <span style="COLOR: rgb(0,0,255)">="en"</span> <span style="COLOR: rgb(255,0,0)"> lang</span> <span style="COLOR: rgb(0,0,255)">="en"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">head</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br />  </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">title</span> <span style="COLOR: rgb(0,0,255)">></</span> <span style="COLOR: rgb(128,0,0)">title</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br />  </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">style </span> <span style="COLOR: rgb(255,0,0)">type</span> <span style="COLOR: rgb(0,0,255)">="text/css"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(128,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />  #search</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">{</span> <span style="COLOR: rgb(255,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />    border</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">:</span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">1px solid #ccc</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">;</span> <span style="COLOR: rgb(255,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />    color</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">:</span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">#999</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">;</span> <span style="COLOR: rgb(255,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />  </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">}</span> <span style="COLOR: rgb(128,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> <br />  </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">style</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br />  </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">script </span> <span style="COLOR: rgb(255,0,0)">type</span> <span style="COLOR: rgb(0,0,255)">="text/javascript"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />  </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"><!--</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />    </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">function</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> addEvent(elm, evType, fn, useCapture)<br />        </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> addEvent and removeEvent</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">        </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> cross-browser event handling for IE5+,  NS6 and Mozilla</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">        </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> By Scott Andrew</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">    {<br />          </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">if</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> (elm.addEventListener){<br />            elm.addEventListener(evType, fn, useCapture);<br />            </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">return</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">true</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">;<br />          } </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">else</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">if</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> (elm.attachEvent){<br />            </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">var</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> r </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> elm.attachEvent(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">on</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">+</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">evType, fn);<br />            </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">return</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> r;<br />          } </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">else</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> {<br />            alert(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">Handler could not be removed</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">);<br />          }<br />    }<br /><br />    </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">function</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> externalLinks(){       </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">讑֮属性rel为external的连接在新页面打开</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">        </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">if</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">!</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">document.getElementsByTagName) </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">return</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> ;<br />        </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">var</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> anchors</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">document.getElementsByTagName(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">a</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">);<br />        </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">for</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">(</span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">var</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> i</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">0</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">;i</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"><</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">anchors.length;i</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">++</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">){<br />            anchor</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">anchors[i];<br />            </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">if</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">(anchor.getAttribute(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">href</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">)</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">&&</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">anchor.getAttribute(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">rel</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">)</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">==</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">external</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">){<br />                anchor.setAttribute(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">target</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">,</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">_blank</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">);<br />            }<br />        }<br />    }<br /><br />    </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">function</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> onSearchFocus(){           </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">搜烦框获取焦Ҏ</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">        </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">var</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> search</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">document.getElementById(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">search</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">);<br />        </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">if</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">(search.value</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">==</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">误入关键字</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">){    </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">如果输入框内Ҏ“请输入关键字”,则清I内容,q设文字颜色ؓ黑色</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">            search.value</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">""</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">;<br />            search.style.color</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">#000</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />        }<br />    }<br />    </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">function</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> onSearchBlur(){            </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">搜烦框失ȝҎ</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">        </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">var</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> search</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">document.getElementById(</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">search</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">);<br />        </span> <span style="COLOR: rgb(0,0,255); BACKGROUND-COLOR: rgb(245,245,245)">if</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">(search.value</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">==</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">""</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">){               </span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">//</span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)">如果输入框内容ؓI,则设定文字颜色ؓ灰色Q内容ؓ“请输入关键子?/span> <span style="COLOR: rgb(0,128,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br /> </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">            search.style.color</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">#999</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">;<br />            search.value</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">=</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">误入关键字</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />        }<br />    }<br />    addEvent(window,</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">load</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">"</span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">,externalLinks)<br />  </span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)">--></span> <span style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"> <br />  </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">script</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">head</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">body</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">p</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br />[External links]</span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">br </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">a </span> <span style="COLOR: rgb(255,0,0)">href</span> <span style="COLOR: rgb(0,0,255)">="http://www.qq.com"</span> <span style="COLOR: rgb(255,0,0)"> rel</span> <span style="COLOR: rgb(0,0,255)">="external"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)">QQ.com</span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">a</span> <span style="COLOR: rgb(0,0,255)">><</span> <span style="COLOR: rgb(128,0,0)">br </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">a </span> <span style="COLOR: rgb(255,0,0)">href</span> <span style="COLOR: rgb(0,0,255)">="http://www.163.com"</span> <span style="COLOR: rgb(255,0,0)"> rel</span> <span style="COLOR: rgb(0,0,255)">="external"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)">163.com</span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">a</span> <span style="COLOR: rgb(0,0,255)">><</span> <span style="COLOR: rgb(128,0,0)">br </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">p</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">p</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br />[internal Links]</span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">br </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">a </span> <span style="COLOR: rgb(255,0,0)">href</span> <span style="COLOR: rgb(0,0,255)">="http://www.blueidea.com"</span> <span style="COLOR: rgb(255,0,0)"> rel</span> <span style="COLOR: rgb(0,0,255)">="internal"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)">BlueIdea.com</span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">a</span> <span style="COLOR: rgb(0,0,255)">><</span> <span style="COLOR: rgb(128,0,0)">br </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">a </span> <span style="COLOR: rgb(255,0,0)">href</span> <span style="COLOR: rgb(0,0,255)">="http://www.51js.com"</span> <span style="COLOR: rgb(255,0,0)"> rel</span> <span style="COLOR: rgb(0,0,255)">="internal"</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)">51Js.com</span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">a</span> <span style="COLOR: rgb(0,0,255)">><</span> <span style="COLOR: rgb(128,0,0)">br </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">p</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">p</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br />[Input Test]</span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">br </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"><</span> <span style="COLOR: rgb(128,0,0)">input </span> <span style="COLOR: rgb(255,0,0)">type</span> <span style="COLOR: rgb(0,0,255)">="text"</span> <span style="COLOR: rgb(255,0,0)"> id</span> <span style="COLOR: rgb(0,0,255)">="search"</span> <span style="COLOR: rgb(255,0,0)"> value</span> <span style="COLOR: rgb(0,0,255)">="误入关键字"</span> <span style="COLOR: rgb(255,0,0)"> size</span> <span style="COLOR: rgb(0,0,255)">="20"</span> <span style="COLOR: rgb(255,0,0)"> onFocus</span> <span style="COLOR: rgb(0,0,255)">="onSearchFocus()"</span> <span style="COLOR: rgb(255,0,0)"> onblur</span> <span style="COLOR: rgb(0,0,255)">="onSearchBlur()"</span> <span style="COLOR: rgb(255,0,0)"> </span> <span style="COLOR: rgb(0,0,255)">/></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">p</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">body</span> <span style="COLOR: rgb(0,0,255)">></span> <span style="COLOR: rgb(0,0,0)"> <br /> </span> <span style="COLOR: rgb(0,0,255)"></</span> <span style="COLOR: rgb(128,0,0)">html</span> <span style="COLOR: rgb(0,0,255)">><br /><br />from indexQ?a >http://www.cnitblog.com/yemoo/archive/2006/06/25/12827.html</a></span> </div> <img src ="http://m.tkk7.com/jaunt/aggbug/105558.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jaunt/" target="_blank">Jaunt</a> 2007-03-22 14:47 <a href="http://m.tkk7.com/jaunt/archive/2007/03/22/105558.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JS验密码安全性等U?收藏)http://m.tkk7.com/jaunt/archive/2007/03/22/105550.htmlJauntJauntThu, 22 Mar 2007 06:16:00 GMThttp://m.tkk7.com/jaunt/archive/2007/03/22/105550.htmlhttp://m.tkk7.com/jaunt/comments/105550.htmlhttp://m.tkk7.com/jaunt/archive/2007/03/22/105550.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/105550.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/105550.html  JS验密码安全性等U:Q首先声?本文非我原作Q?br />  <STYLE type=text/css>
    body {
    font-size: 12px;
    font-family: Tahoma, Arial;
    background: #C4C8CB;
    margin: 0px;
    padding: 0px;
    }
    td {
    padding-left: 5px;
    font-size: 12px;
    font-family: Tahoma, Arial;
    }
    .blueFont {color: #6699CC}
    .redFont {color: #FF0000}
    /***** Other Elements in Page Content *****/
    .pwd-strength {
    padding: 2px;
    padding-left: 5px;
    padding-right: 5px;
    width: 180px;
    border: solid 1px #CCCCCC;
    }
    .pwd-strength-box,
    .pwd-strength-box-low,
    .pwd-strength-box-med,
    .pwd-strength-box-hi
    {
    color: #464646;
    text-align: center;
    width: 33%;
    }
    .pwd-strength-box-low
    {
    color: #990000;
    background-color: #FFECEC;
    }
    .pwd-strength-box-med
    {
    color: #000066;
    background-color: #D2E9FF;
    }
    .pwd-strength-box-hi
    {
    color: #003300;
    background-color: #DDFFDD;
    }
    </STYLE>
    <SCRIPT language=javascript>
    function checkPassword(pwd){
    var objLow=document.getElementById("pwdLow");
    var objMed=document.getElementById("pwdMed");
    var objHi=document.getElementById("pwdHi");
    objLow.className="pwd-strength-box";
    objMed.className="pwd-strength-box";
    objHi.className="pwd-strength-box";
    if(pwd.length<6){
    objLow.className="pwd-strength-box-low";
    }else{
    var p1= (pwd.search(/[a-zA-Z]/)!=-1) ? 1 : 0;
    var p2= (pwd.search(/[0-9]/)!=-1) ? 1 : 0;
    var p3= (pwd.search(/[^A-Za-z0-9_]/)!=-1) ? 1 : 0;
    var pa=p1+p2+p3;
    if(pa==1){
    objLow.className="pwd-strength-box-low";
    }else if(pa==2){
    objMed.className="pwd-strength-box-med";
    }else if(pa==3){
    objHi.className="pwd-strength-box-hi";
    }
    }
    }
    </SCRIPT>
    <BR>
    <TABLE borderColor=#ffffff cellSpacing=0 borderColorDark=#eeeeee cellPadding=0 width=400 align=center bgColor=#ffffff border=1>
    <TBODY>
    <TR>
    <TD align=middle bgColor=#ffffcc colSpan=2 height=22><SPAN class=blueFont><B>校验密码安全?lt;/B></SPAN></TD></TR>
    <TR>
    <TD style="WIDTH: 100px">误入密码:</TD>
    <TD><INPUT onkeyup=checkPassword(this.value); type=password value="" name=password></TD></TR>
    <TR>
    <TD style="WIDTH: 100px">安全性等U:</TD>
    <TD>
    <TABLE class="pwd-strength FCK__ShowTableBorders" cellSpacing=0 cellPadding=0 width="100%">
    <TBODY>
    <TR>
    <TD class=pwd-strength-box id=pwdLow>?lt;/TD>
    <TD class=pwd-strength-box id=pwdMed>?lt;/TD>
    <TD class=pwd-strength-box id=pwdHi>?lt;/TD></TR></TBODY></TABLE></TD></TR>
    <TR>
    <TD colSpan=2><SPAN class=redFont>臛_ 6 个字W? 请用强密码以保证安?</SPAN></TD></TR></TBODY></TABLE>

from indexQ?
http://www.cnitblog.com/yemoo/archive/2006/07/04/13219.html


Jaunt 2007-03-22 14:16 发表评论
]]>JavaScript中的l承(?http://m.tkk7.com/jaunt/archive/2006/11/28/84173.htmlJauntJauntTue, 28 Nov 2006 15:14:00 GMThttp://m.tkk7.com/jaunt/archive/2006/11/28/84173.htmlhttp://m.tkk7.com/jaunt/comments/84173.htmlhttp://m.tkk7.com/jaunt/archive/2006/11/28/84173.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/84173.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/84173.html  作者:
Flyingis 
  原蝲Q?/font>http://m.tkk7.com/flyingis/archive/2006/07/15/58339.html
    Prototype

   
我们了解CQ何prototype的属性和Ҏ都会被传递到该类的所有实例中Q利用这一Ҏ,使用prototype也能实现l承?
 
  functionClassA() {
}


ClassA.prototype.id
= 1998;
 ClassA.prototype.sayId
=function(){
   alert(
this.id);
}
;

functionClassB(){
}


ClassB.prototype
=newClassA();
ClassB.prototype.name
="";
 ClassB.prototype.sayName
=function(){
   alert(
this.name);
}

    需要注意的是,q种实现l承的方法不能将参数传入到ClassA的构造器中,是一个缺陗ClassB的所有属性和Ҏ必需在将ClassB?prototype对象指向ClassA的实例之后进行附倹{这样做是因为,prototype指向一个新的对象,在此之前prototype的属性和Ҏ都被覆盖销毁?br />
    对代码进行测试:

var obj1 =newClassA();
var obj2=new ClassB();
obj1.id
= 1998;
obj2.id
= 2000;
obj2.name
="悉尼奥运?/span>";
obj1.sayId();  
//输出"1998"
obj2.sayId();  //输出"1998"
obj2.sayName();  //输出"悉尼奥运?

alert(obj2
instanceofClassA);  //输出"true"
alert(obj2 instanceofClassB);  //输出"true"

    在上qC码中可以看出Q用prototype实现l承Qinstanceof操作W出C另外的用途,在用构造v定义cd现承时Qinstanceof不会出现q种效果。但是用prototype不能支持多重l承?br />  
    使用构造器定义cd现承和使用prototype实现l承均存在各自的~陷Q要避免出现q些情况Q只有将两者؜合用?br />
    混合Ҏ

    创徏一个类的最x法,是用构造器的方法去定义属性,使用prototype定义Ҏ。在l承中同样如此?br />
  functionClassA(id) {
  
this.id =id;
}


  ClassA.prototype.sayId
= function() {
   alert(
this.id);
}
;

function ClassB(id, name) {
   ClassA.call(
this, id);
  
this.name =name;
}


ClassB.prototype
=  new ClassA();
 ClassB.prototype.sayName
=function(){
   alert(
this.name);
}


Jaunt 2006-11-28 23:14 发表评论
]]>JavaScript 中的l承(?http://m.tkk7.com/jaunt/archive/2006/11/28/84161.htmlJauntJauntTue, 28 Nov 2006 14:51:00 GMThttp://m.tkk7.com/jaunt/archive/2006/11/28/84161.htmlhttp://m.tkk7.com/jaunt/comments/84161.htmlhttp://m.tkk7.com/jaunt/archive/2006/11/28/84161.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/84161.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/84161.html作者:
Flyingis
原蝲Q?/font> http://m.tkk7.com/flyingis/archive/2006/07/15/58290.html

    l承是面向对象语a基本特征之一Q通过l承可以父cLh的特性遗传到子类。ECMAScript中的l承不像Java、C++{语a那么明显Q直接通过关键字来实现Q通常它是通过模拟方式来实现承功能的Qƈ且实现方式有多种?br />
    在承中引入this关键字,使用构造器Ҏ定义cL实现l承。一个构造器是一个函敎ͼ因此可以父cȝ构造器作ؓ子类的一个方法用ƈq行调用?br />

  functionClassA(id)  {
  
this .id =
id;
  
this .sayId = function()
{
     alert(
this
.id);
   }
;
}


 
function ClassB(id, name)  {
  
this .newMethod =
ClassA;
  
this
.newMethod(id);
  
delete this.
newMethod;

  
this .name =
name;
  
this .sayName = function()
{
     alert(
this
.name);
   }
;
}

    注意Q子cM所有新的属性和Ҏ都必需在删除newMethod后引入,否则Q可能存在用父类的属性和Ҏ重写子类属性和Ҏ的危险。另外,使用q种Ҏq可以实现多重承,此时如果两个父类h相同的属性或ҎӞ最后的cd有优先。由于这U承方法比较流行,ECMAScriptW三版引入了两个 Function对象Qcall()和apply()?br />
    call()

    call()Ҏ是最接近上述l承方式的方法,它的W一个参数是this指向的对象,所有的其他参数都直接传到function?br />

  functionsayMessage(first, last) {
   alert(first
+ this.logic +last);
}
;

varobj =new Object();
obj.logic
= "or";

sayMessage.call(obj,
"Coffee ""Tea");  //输出"Coffee or Tea"

    用call()Ҏ来实现承,只需要this.newMethod相关的三行代码?br />

  functionClassB(id, name) {
  
  //this.newMethod = ClassA;
  //this.newMethod(id);
  //delete this.newMethod;
  ClassA.call(this, id);  //this指向ClassB的对?/span>

  
this.name =name;
  
this.sayName = function() {
     alert(
this.name);
   }
;
}

    apply()

    apply()Ҏ需要两个参敎ͼthis所指向的对象,和传到function的由参数l成的array?br />
function sayMessage(first, last)  {
  alert(first 
+ this.logic +last);
}
;

var obj = new Object();
obj.logic 
= "or";

sayMessage.apply(obj, 
new Array("Coffee "" Tea"));  //输出"Coffee or Tea"
  
    同样Q?apply() 实现l承可以通过如下Ҏ实现?br />
function ClassB(id, name) {
  
//this.newMethod = ClassA;
  //this.newMethod(id);
  //delete this.newMethod;
  ClassA.apply(thisnew Array(id));  //this指向ClassB的对?/span>

  
this.name = name;
  
this.sayName = function() {
    alert(
this.name);
  }
;
}

    当父cL造器的参数和子类构造器参数的顺序一致时Q可以用子cȝarguments对象作ؓW二个参数。否则,必需创徏一个array来传递参敎ͼ或是使用call()Ҏ?br />
    文章待箋…?/font>


Jaunt 2006-11-28 22:51 发表评论
]]>"this" of JavaScript你理解有多少Q?/title><link>http://m.tkk7.com/jaunt/archive/2006/11/27/83825.html</link><dc:creator>Jaunt</dc:creator><author>Jaunt</author><pubDate>Mon, 27 Nov 2006 08:48:00 GMT</pubDate><guid>http://m.tkk7.com/jaunt/archive/2006/11/27/83825.html</guid><wfw:comment>http://m.tkk7.com/jaunt/comments/83825.html</wfw:comment><comments>http://m.tkk7.com/jaunt/archive/2006/11/27/83825.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jaunt/comments/commentRss/83825.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jaunt/services/trackbacks/83825.html</trackback:ping><description><![CDATA[ <font face="Verdana" size="2">译者:<a href="/flyingis/" target="_blank"><font color="#000080">Flyingis</font></a><br />~辑Q?a href="/jaunt">Jaunt<br /></a>原蝲Q?a href="/flyingis/archive/2006/09/15/69888.html">http://m.tkk7.com/flyingis/archive/2006/09/15/69888.html</a><br /><br />this是JavaScript中功能最强大的关键字之一?br /></font> <h3 id="link1"> <font face="Verdana" size="2">Owner</font> </h3> <p> <font face="Verdana" size="2">接下来文章中我们要讨论的问题是Q在函数doSomething()中this所指的是什么?<br /></font> <br /> </p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"> <font size="2"> <font face="Verdana"> <img id="Codehighlighter1_23_57_Open_Image" onclick="this.style.display='none'; Codehighlighter1_23_57_Open_Text.style.display='none'; Codehighlighter1_23_57_Closed_Image.style.display='inline'; Codehighlighter1_23_57_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <span style="COLOR: rgb(0,0,255)">function</span> <span style="COLOR: rgb(0,0,0)"> doSomething() </span> <span id="Codehighlighter1_23_57_Closed_Text" style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"> </span> </font> </font> <span id="Codehighlighter1_23_57_Open_Text"> <font size="2"> <font face="Verdana"> <span style="COLOR: rgb(0,0,0)">{<br /><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span> <span style="COLOR: rgb(0,0,255)">this</span> <span style="COLOR: rgb(0,0,0)">.style.color </span> <span style="COLOR: rgb(0,0,0)">=</span> </font> </font> <span style="COLOR: rgb(0,0,0)"> <font size="2"> <font face="Verdana"> '#cc0000';<br /><strong><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</strong></font> </font> </span> </span> </div> <br /> <font face="Verdana" size="2">在JavaScript中,this通常指向的是我们正在执行的函数本w,或者是Q指向该函数所属的对象。当我们在页面中定义了函数doSomething()的时候,或者是JavaScript中的window对象Q或global对象Q。对于一个onclick属性,它ؓ它所属的HTML元素所拥有Qthis应该指向该HTML元素?br /><br />q种“所有权”就是JavaScript中面向对象的一U方式。?br /></font> <p> </p> <p align="center"> <font face="Verdana" size="2"> <img height="260" alt="this1.gif" src="http://m.tkk7.com/images/blogjava_net/flyingis/this1.gif" width="530" border="0" /> </font> </p> <font face="Verdana" size="2">如果我们在没有Q何更多准备情况下执行doSomething()Qthis关键字会指向windowQƈ且该函数试图改变window?style.color。因为windowq没有style对象Q这个函数将非常不幸的运行失败,q生JavaScript错误?br /><br /></font> <font face="Verdana"> <font size="2"> <strong>Copying<br /></strong>  <br />因此如果我们惛_分利用thisQ我们不得不注意使用this的函数应该被正确的HTML元素所拥有。换句话_我们应该复制q个函数到我们的onclick属性?/font> </font> <font face="Verdana" size="2"> <br /> </font> <strong> <br /> </strong> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"> <font face="Verdana" size="2"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </font> <span style="COLOR: rgb(0,0,0)">element.onclick </span> <span style="COLOR: rgb(0,0,0)">=</span> <span style="COLOR: rgb(0,0,0)"> doSomething;</span> </div> <font face="Verdana" size="2"> <br />q个函数被完整复制到onclick属性(现在成ؓ了函敎ͼ。因此如果这个event handler被执行,this指向HTML元素Qƈ且该元素的颜色得以改变?br /><br /><p align="center"><img height="258" alt="this2.gif" src="http://m.tkk7.com/images/blogjava_net/flyingis/this2.gif" width="529" border="0" /></p>q种Ҏ使得我们能够复制q个函数到多个event handler。每ơthis都将指向正确的HTML元素Q?br /><br /><p align="center"><img height="416" alt="this3.gif" src="http://m.tkk7.com/images/blogjava_net/flyingis/this3.gif" width="532" border="0" /></p><br />q样你就可以最大限度用this。每当执行该函数Qthis所指向的HTML元素都正响应事Ӟq些HTML元素拥有doSomething()的一个拷贝?br /><br /><strong>Referring<br /><br /></strong>然而,如果你?a target="_blank"><font color="#000080">inline event registration</font></a>(内联事g注册)<br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: rgb(0,0,255)"><</span><span style="COLOR: rgb(128,0,0)">element </span><span style="COLOR: rgb(255,0,0)">onclick</span><span style="COLOR: rgb(0,0,255)">="doSomething()"</span><span style="COLOR: rgb(0,0,255)">></span></div><br />你将不能拯该函敎ͼ反而这U差异是非常关键的。onclick属性ƈ不包含实际的函数Q仅仅是一个函数调用?br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: rgb(0,0,0)">doSomething();</span></div><br />因此Q它声明“{到doSomething()q且执行它”。当我们到达doSomething()Qthis关键字又重新指向了全局的window对象Q函数返回错误信息?br /><br /><p align="center"><img height="276" alt="this4.gif" src="http://m.tkk7.com/images/blogjava_net/flyingis/this4.gif" width="530" border="0" /></p><font size="3"><strong>The difference</strong></font><br /><br />如果你想使用this来指向HTML元素响应的事Ӟ你必ȝ保this关键字被写在onclick属性里。只有在q种情况下它才指向event handler所注册的HTML元素?br />  <br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: rgb(0,0,0)">element.onclick </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> doSomething;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />alert(element.onclick)</span></div><br />你将得到<br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img id="Codehighlighter1_23_57_Open_Image" onclick="this.style.display='none'; Codehighlighter1_23_57_Open_Text.style.display='none'; Codehighlighter1_23_57_Closed_Image.style.display='inline'; Codehighlighter1_23_57_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><span style="COLOR: rgb(0,0,255)">function</span><span style="COLOR: rgb(0,0,0)"> doSomething() </span><span id="Codehighlighter1_23_57_Closed_Text" style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"></span><span id="Codehighlighter1_23_57_Open_Text"><span style="COLOR: rgb(0,0,0)">{<br /><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span><span style="COLOR: rgb(0,0,255)">this</span><span style="COLOR: rgb(0,0,0)">.style.color </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> '#cc0000';<br /><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div><br />正如你所见,this关键字被展现在onclick函数中,因此它指向HTML元素?br />但是如果执行<br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: rgb(0,0,255)"><</span><span style="COLOR: rgb(128,0,0)">element </span><span style="COLOR: rgb(255,0,0)">onclick</span><span style="COLOR: rgb(0,0,255)">="doSomething()"</span><span style="COLOR: rgb(0,0,255)">></span><span style="COLOR: rgb(0,0,0)"><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />alert(element.onclick)</span></div><br />你将得到<br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img id="Codehighlighter1_19_37_Open_Image" onclick="this.style.display='none'; Codehighlighter1_19_37_Open_Text.style.display='none'; Codehighlighter1_19_37_Closed_Image.style.display='inline'; Codehighlighter1_19_37_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><span style="COLOR: rgb(0,0,255)">function</span><span style="COLOR: rgb(0,0,0)"> onclick() </span><span id="Codehighlighter1_19_37_Closed_Text" style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"></span><span id="Codehighlighter1_19_37_Open_Text"><span style="COLOR: rgb(0,0,0)">{<br /><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />  doSomething()<br /><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div><br />q仅仅是到doSomething()函数的一个引用。this关键字ƈ没有出现在onclick函数中,因此它不指向HTML元素?/font> <img src ="http://m.tkk7.com/jaunt/aggbug/83825.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jaunt/" target="_blank">Jaunt</a> 2006-11-27 16:48 <a href="http://m.tkk7.com/jaunt/archive/2006/11/27/83825.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>认识for…in 循环语句http://m.tkk7.com/jaunt/archive/2006/11/26/83562.htmlJauntJauntSun, 26 Nov 2006 02:09:00 GMThttp://m.tkk7.com/jaunt/archive/2006/11/26/83562.htmlhttp://m.tkk7.com/jaunt/comments/83562.htmlhttp://m.tkk7.com/jaunt/archive/2006/11/26/83562.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/83562.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/83562.html for...in循环的JavascriptCZQ?/strong>
<html>
<head>
<title>一个用到for...in循环的JavascriptCZ</title>
</head>
<body>
<script type="text/javascript">
// 创徏一个对?myObject 以及三个属?sitename, siteurl, sitecontent?br />var myObject = new Object();
myObject.sitename = "布啦布啦";
myObject.siteurl = "blabla.cn";
myObject.sitecontent = "|页教程代码囑ֺ的中文站?;
//遍历对象的所有属?br />for (prop in myObject)
{
document.write("属?'" + prop + "' ?" + myObject[prop]);
document.write("<br>");
}
</script>
</body>
</html>

今天|上Java Tang博客扑ֈ了一个用来遍历JavaScript某个对象所有的属性名U和值的ҎQ这h使用Ҏ的时候非常的直观和方ѝ代码如下:
  1. /*
  2. * 用来遍历指定对象所有的属性名U和?/span>
  3. * obj 需要遍历的对象
  4. * author: Jet Mah
  5. * website: http://www.javatang.com/archives/2006/09/13/442864.html
  6. */
  7. function   allPrpos ( obj ) {
  8.     // 用来保存所有的属性名U和?
  9.     var   props = "" ;
  10.     // 开始遍?
  11.     for ( var   p in obj ){  
  12.         // Ҏ
  13.         if ( typeof ( obj [ p ]) == " function " ){  
  14.             obj [ p ]() ;
  15.         } else {  
  16.             // p 为属性名Uͼobj[p]为对应属性的?
  17.             props += p + " = " + obj [ p ] + " \t " ;
  18.         }  
  19.     }  
  20.     // 最后显C所有的属?
  21.     alert ( props ) ;
  22. }

AJAX的JavaScript的反机?反射机制指的是程序在q行时能够获取自w的信息。例如一个对象能够在q行时知道自己有哪些Ҏ和属性?在JavaScript中利用for(…in?语句实现反射Q其语法如下Q?/strong>

for(var p in obj){
//语句
}

在Ajax~程中,l常要能动态的改变界面元素的样式,q可以通过对象的style属性来改变Q比如要改变背景色ؓU色Q可以这样写Q?br />element.style.backgroundColor="#ff0000";

基本上CSS里拥有的属性在JavaScript中都能够使用Q?br />function setStyle(_style){
//得到要改变样式的界面对象
var element=getElement();
element.style=_style;
}

直接整个style对象作ؓ参数传递了q来Q?br />var style={
color:#ffffff,
backgroundColor:#ff0000,
borderWidth:2px
}

q时可以q样调用函数Q?br />setStyle(style);

或者直接写为:
setStyle({ color:#ffffff,backgroundColor:#ff0000,borderWidth:2px});

q段代码看上L有Q何问题,但实际上Q在setStyle函数内部使用参数_style为element.style赋值时Q如果element原先已经有了一定的样式Q例如曾l执行过Q?br />element.style.height="20px";

而_style中却没有包括对height的定义,因此element的height样式׃׃Q不是最初所要的l果。要解决q个问题Q可以用反射机制来重写setStyle函数Q?br />function setStyle(_style){
//得到要改变样式的界面对象
var element=getElement();
for(var p in _style){
element.style[p]=_style[p];
}
}

E序中遍历_style的每个属性,得到属性名Uͼ然后再用方括号语法element.style中的对应的属性赋gؓ_style中的相应属性的倹{从而,element中仅改变指定的样式,而其他样式不会改变,得到了所要的l果。^-^



Jaunt 2006-11-26 10:09 发表评论
]]>JavaScript 调试工具http://m.tkk7.com/jaunt/archive/2006/11/25/83535.htmlJauntJauntSat, 25 Nov 2006 14:32:00 GMThttp://m.tkk7.com/jaunt/archive/2006/11/25/83535.htmlhttp://m.tkk7.com/jaunt/comments/83535.htmlhttp://m.tkk7.com/jaunt/archive/2006/11/25/83535.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/83535.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/83535.htmlJavaScript 调试工具 

    作者:Flyingis
 
    JavaScript代码看v来L要比Java、C#q多,可能是自p不熟悉JavaScript~程Q因此一ƾ优U的JavaScript调试器就昑־格外重要。目前在|络和书上见到最多的有:

    Microsoft Script Debugger: 集成在IE中的一Ƒ־原始的调试工P具备基本的调试功能,除了可以用于调试客户端脚本,q能调试在Microsoft IIS上运行的服务器端脚本。该工具命oH口是基于文本的Q针对VBScript和IE环境q行调试会更加适用?
 
    Firefox JavaScript Console: 可以记录JavaScript中出现的所有警告和错误Q诊断出大多数错误。工h较简单实用?
 
    Venkman: 一个基于Mozilla的浏览器的JavaScript调试环境Q是Mozilla览器的一个扩展。VenkmanZMozilla JavaScript调试APIQjs/jsdQ,js/jsd API 构成?Netscape JavaScript Debugger 1.1的基QNetscape览?.xpȝ都提供了q个调试工具。Venkman是目前比较流行的JavaScript调试工具?/p>

    相关下蝲Q?br />    http://www.hacksrus.com/~ginda/venkman/
    上面最新的版本?.9.85Q对于Firefox只能支持1.5以前的版本?br />    https://dwr.dev.java.net/files/documents/2427/22010/venkman-0.9.85.jw2.xpi
    venkman-0.9.85.jw2.xpi是venkman-0.9.85xpi的修改版本,可以支持Firefox 1.5.0。?br />    https://addons.mozilla.org/firefox/216/
    在Mozilla官方站点上,venkman有了另外的一个名U——JavaScript DebuggerQ已l发布了0.9.87版本Q支   持Firefox 0.9-3.0QMozilla 1.0-1.8QThunderbird 0.9-3.0的所有版本浏览器?br />    除了官方|站外,该工L扩展安装也可以通过链接
    http://m.tkk7.com/Files/flyingis/javascript_debugger-0.9.87.rarq行本地下蝲?br /> 
    另外有一些JavaScript专用IDEQ有兴趣可以试用一下:
 
    Cardinal JavaScript IDE:
   
    JavaScript IDE for Eclipse:
   
    JavaScript IDE(׃n软g):

----------------------------------------------------------------------------------------------------

本h现在用的?a >firebugQ是一个非常好的小工具集合Q它的一些小功能非常方便。比以上的都?...

  

Jaunt 2006-11-25 22:32 发表评论
]]>
JavaScriptQ世界上误解最q语言(转蝲)http://m.tkk7.com/jaunt/archive/2006/11/25/83401.htmlJauntJauntFri, 24 Nov 2006 16:24:00 GMThttp://m.tkk7.com/jaunt/archive/2006/11/25/83401.htmlhttp://m.tkk7.com/jaunt/comments/83401.htmlhttp://m.tkk7.com/jaunt/archive/2006/11/25/83401.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/83401.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/83401.html JavaScript:The World's Most Misunderstood Programming Language

JavaScriptQ世界上误解最q语言

Douglas Crockford

译Q袁晓辉

JavaScript, aka Mocha, aka LiveScript, aka JScript, aka ECMAScript, is one of the world's most popular programming languages. Virtually every personal computer in the world has at least one JavaScript interpreter installed on it and in active use. JavaScript's popularity is due entirely to its role as the scripting language of the WWW.

JavaScriptQ或者叫 MochaQ或者叫 LiveScriptQ或者叫 JScriptQ又或者叫 ECMAScriptQ是世界上最行的编E语a之一。事实上世界上的每一C人电脑都安装q在频繁使用臛_一个JavaScript解释器?JavaScript的流行完全是׃他在WWW脚本语言领域中的C军_的?br />
Despite its popularity, few know that JavaScript is a very nice dynamic object-oriented general-purpose programming language. How can this be a secret? Why is this language so misunderstood?

管它很行Q但是很有人知道JavaScript是一个非常棒的动态面向对象通用~程语言。这居然能成Z个秘密!q门语言Z么被误解如此之深Q?br />
The Name
名字

The Java- prefix suggests that JavaScript is somehow related to Java, that it is a subset or less capable version of Java. It seems that the name was intentionally selected to create confusion, and from confusion comes misunderstanding. JavaScript is not interpreted Java. Java is interpreted Java. JavaScript is a different language.

Java- 前缀很容易惛_JavaQƈ认ؓ它是Java的子集或化版的Java。看h最初给它选这个名字是别有用心的,是故意؜淆概c故意制?误解" 的。JavaScript不是解释执行的Java。Java是解释执行的Java。JavaScript是另外一U语a?br />
JavaScript has a syntactic similarity to Java, much as Java has to C. But it is no more a subset of Java than Java is a subset of C. It is better than Java in the applications that Java (fka Oak) was originally intended for.

JavaScript的语法和Java有相g处,q就像Java的语法和C很相像一栗但是它不是Java的子集,像Java不是C的子集一栗它在JavaQOakQ最初打进军的领域中比Java更好?br />
JavaScript was not developed at Sun Microsystems, the home of Java. JavaScript was developed at Netscape. It was originally called LiveScript, but that name wasn't confusing enough.

JavaScript不是Sun Microsystems的品,Sun是Java的家。JavaScript是在Netscape被开发出来的。它最初叫LiveScriptQ嗯……还是这个名字好?br />
The -Script suffix suggests that it is not a real programming language, that a scripting language is less than a programming language. But it is really a matter of specialization. Compared to C, JavaScript trades performance for expressive power and dynamism.

-Script后缀让h认ؓ他不是一门真正的~程语言Q和一?~程语言"q有相当的差距。但是这只是应用领域的问题。和C相比QJavaScript是牺牲了性能但换来了丰富的表现力和灵zȝ形态?br />
Lisp in C's Clothing
披着C皮的Lisp

JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.

JavaScript的类C语法Q包括大括号和语句的形式Q让它看h像普通的面向q程~程语言。这是一U误解,因ؓJavaScript和函数式语言Q比?Lisp ?SchemeQ有更多的相g处,而不是和C或Java。它使用数组而不是列表,使用对象而不是属性列表。函数是W一位的Q它有闭包(closures 怎么译Q?Q,另外你还可以使用lambda表达式?br />
Typecasting
cd转换

JavaScript was designed to run in Netscape Navigator. Its success there led to it becoming standard equipment in virtually all web browsers. This has resulted in typecasting. JavaScript is the George Reeves of programming languages. JavaScript is well suited to a large class of non-Web-related applications

JavaScript最初被设计成在Netscape Navigator中运行,它在Navigator中的成功引领它成Z实上所有web览器的标准装备。这造就?cd转换"。JavaScript 是编E语a中的 George ReevesQ超人)Q是大量非webE序的称职之选?br />
Moving Target
Ud?br />
The first versions of JavaScript were quite weak. They lacked exception handling, inner functions, and inheritance. In its present form, it is now a complete object-oriented programming language. But many opinions of the language are based on its immature forms.

JavaScript的最初几版非常弱Q没有异常处理,没有内部函数和ѝ现如今Q它已经成ؓ完全面向对象的编E语a。但是这门语a的许多思想是基于它不成熟的形式的?br />
The ECMA committee that has stewardship over the language is developing extensions which, while well intentioned, will aggravate one of the language's biggest problems: There are already too many versions. This creates confusion.

ECMA委员会,q门语言的管Ӟ正在对它q行扩展Q也在蓄意恶化它最大的问题Q有太多的版本。这是؜qҎ?br />
Design Errors
设计上的错误

No programming language is perfect. JavaScript has its share of design errors, such as the overloading of + to mean both addition and concatenation with type coercion, and the error-prone with statement should be avoided. The reserved word policies are much too strict. Semicolon insertion was a huge mistake, as was the notation for literal regular expressions. These mistakes have led to programming errors, and called the design of the language as a whole into question. Fortunately, many of these problems can be mitigated with a good lint program.

没有什么编E语a是完的。JavaScript也有它设计上的错误,比如重蝲?号随着cd的不同既表示"相加"又表C?q接"Q和本该避免的有错误們֐?with 语句。它的保留字{略q于严格。分L插入是一个巨大的错误Q比如作为字面正则表辑ּ的符h。这些失误已直接D~程中的错误Q也使这门语a的整体设计遭疑。还好,q些问题中有许多都可以在良好?lint E序中得以缓解?br />
The design of the language on the whole is quite sound. Surprisingly, the ECMAScript committee does not appear to be interested in correcting these problems. Perhaps they are more interested in making new ones.

q门语言的整体设计(上的问题Q是相当明显的。奇怪的是ECMAScript委员会ƈ没有对修正其中存在的问题表现出太大的兴趣Q也总们更热衷于制造新的问题?br />
Lousy Implementations
p糕的实?br />
Some of the earlier implementations of JavaScript were quite buggy. This reflected badly on the language. Compounding that, those implementations were embedded in horribly buggy web browsers.

JavaScript的一些早期实现有许多bugQ这反过来对语言本n产生了很坏的影响。更p糕的是q些满是bug的实现是嵌入在满是bug的web览器中的?br />
Bad Books
p糕的书

Nearly all of the books about JavaScript are quite awful. They contain errors, poor examples, and promote bad practices. Important features of the language are often explained poorly, or left out entirely. I have reviewed dozens of JavaScript books, and I can only recommend one: JavaScript: The Definitive Guide (4th Edition) by David Flanagan. (Attention authors: If you have written a good one, please send me a review copy.)

几乎所有的JavaScript书都是相当可怕的。它们包含错误,包含不好的例子,q׃好的做法?JavaScript语言的一些重要特性它们要么没有解释清楚,要么Ҏ没有提及。我看过很多JavaScript的书Q但我只能推荐一本:David Flanagan著的 JavaScript: The Definitive Guide (4th Edition) Q《JavaScript权威指南 W四版》)。(作者们h意:如果你们写出了好书请发给我一份副本,我给你们校对。)

Substandard Standard
“准标准”的标准

The official specification for the language is published by ECMA. The specification is of extremely poor quality. It is difficult to read and very difficult to understand. This has been a contributor to the Bad Book problem because authors have been unable to use the standard document to improve their own understanding of the language. ECMA and the TC39 committee should be deeply embarrassed.

ECMA公布的官方语a规范的质量极其的差。不仅难读而且极其难懂。它可ؓ那些"p糕的书"做出了不的贡献Q因为那些作者无法通过q个标准文档来更深地理解q门语言。ECMA和TC39应该为此感到非常尬?br />
Amateurs
业余?br />
Most of the people writing in JavaScript are not programmers. They lack the training and discipline to write good programs. JavaScript has so much expressive power that they are able to do useful things in it, anyway. This has given JavaScript a reputation of being strictly for the amateurs, that it is not suitable for professional programming. This is simply not the case.

使用JavaScript的h大多不是E序员,他们~少写良好程序的培训和训l。JavaScript有非常强大的表现力,不管怎样他们也能使用它做有用的事情。这l了JavaScript一个”全焉合业余爱好者而不适合专业E序员“的名声。这很明显是一个错误?br />
Object-Oriented
面向对象

Is JavaScript object-oriented? It has objects which can contain data and methods that act upon that data. Objects can contain other objects. It does not have classes, but it does have constructors which do what classes do, including acting as containers for class variables and methods. It does not have class-oriented inheritance, but it does have prototype-oriented inheritance.

JavaScript是面向对象的吗?它有对象Q它的对象可以包含数据以及对数据q行操作的方法,对象也可以包含其他的对象。它没有c,但是它有构造函数来做类的事情,包括声明cȝ变量和方法。它没有面向cȝl承Q但是他有面向原型的l承?br />
The two main ways of building up object systems are by inheritance (is-a) and by aggregation (has-a). JavaScript does both, but its dynamic nature allows it to excel at aggregation.

构徏对象pȝ的两大主要方法是l承Qis-aQ和聚合Qhas-aQ。这两者JavaScript都有Q但是它的动态天性允许有比聚合更好的实现方式?br />
Some argue that JavaScript is not truly object oriented because it does not provide information hiding. That is, objects cannot have private variables and private methods: All members are public.

一些关于JavaScript不是真的面向对象的争论其理由是它没有提供信息隐藏。也是说JavaScript的对象没有私有变量和U有ҎQ它的所有成员都是公开的?br />

But it turns out that JavaScript objects can have private variables and private methods. (Click here now to find out how.) Of course, few understand this because JavaScript is the world's most misunderstood programming language.

但是事实是JavaScript 的对象可以有U有变量和私有方法(点击q里来看如何实现Q。当Ӟ之所以很有人知道这个是因ؓJavaScript是世界上误解最q语言嘛?br />
Some argue that JavaScript is not truly object oriented because it does not provide inheritance. But it turns out that JavaScript supports not only classical inheritance, but other code reuse patterns as well.

另一些关于JavaScript不是真的面向对象的争论其理由是它没有提供l承。但是事实是JavaScript不但支持l典的承,而且支持其他一些代码重用的模式?br />
Copyright 2001 Douglas Crockford. All Rights Reserved Wrrrldwide.版权所?lt;?gt;

http://www.crockford.com/javascript/javascript.html

Jaunt 2006-11-25 00:24 发表评论
]]>
JavaScript中的Booleancdhttp://m.tkk7.com/jaunt/archive/2006/11/24/83354.htmlJauntJauntFri, 24 Nov 2006 11:11:00 GMThttp://m.tkk7.com/jaunt/archive/2006/11/24/83354.htmlhttp://m.tkk7.com/jaunt/comments/83354.htmlhttp://m.tkk7.com/jaunt/archive/2006/11/24/83354.html#Feedback0http://m.tkk7.com/jaunt/comments/commentRss/83354.htmlhttp://m.tkk7.com/jaunt/services/trackbacks/83354.html今天看到
Oo~来是你oO 的博客,关于Boolean cd一些问题如下:

正文Q?br />JavaScript中的Booleancd

1.   我们所熟悉?br />
var x = false;
var y = true;

q是我们大家都熟悉的Q此时我们用的是原始的Boolean|the primitive Boolean values Qtrue和false

2.   我们很少用到?/font>

var xObject = new Boolean(false);
var yObject = new Boolean(true);

此时我们声明了一?font color="#0000ff">Boolean对象
QBoolean对象是对Boolean值的一个封装?br />Boolean对象Q一个gؓtrue或false的Boolean对象?br />
原始的Boolean值和Boolean对象是有区别的,不要怺hQ引?font color="#0000ff">Core JavaScript 1.5 Reference
中的一句话Q?/font>
Do not confuse the primitive Boolean values true and false with the true and false values of the Boolean object.


3.   区别

区别Q?Q:   声明形式

区别Q?Q:   在条件语句(condition statementQ中

var  x  =   false ;
var  xObject  =   new  Boolean( false
);

if
(x)
    alert(
" x = true "
);
else

    alert(
" x = false " );

if
(xObject)
    alert(
" xObject =  "   +  xObject  +   " , but in the condition statement, the xObject value is evaluated to true "
);
else

    alert(
" xObject = false " );

输出l果Q?br />
=   false
xObject 
=   false,  but in the condition statement, the xObject value is evaluated to true

区别Q?Q:初始化Boolean对象

声明一个Boolean对象Q如果我们用一个gؓfalse的Boolean对象对其q行初始化,则新的Boolean对象的gؓtrue

var  xObject  =   new  Boolean( false );
var  resXObject  =   new
 Boolean(xObject);
alert(
" The resXObject value is  "   +  resXObject);

Oo~来是你oO 的博客中 马嘉?/font>  遇到q个问题Q查了一些资料才知道Q学无止境啊。可是我的问题依然没有解冟?br />我的问题是关于Boolean对象的初始化。代码如下,

var  ob1  =   new  Boolean( false );
var  ob2  =  (ob1 && true
);
var  ob3  =  ( true &&
ob1);
var  ob4  =  Boolean(ob1 && true
);
var  ob5  =  Boolean( true &&
ob1);
alert(
" ob2 =  "   +  ob2  +   "  ob3 =  "   +  ob3  +   "  ob4 =  "   +  ob4  +   "  ob5 =  "   +  ob5);

l果Q?br />
ob2  =   true  ob3  =   false  ob4  =   true  ob5  =   true

问题已经解决Q?/font>

||是这栯的Q从W一个开始,遇到有意义的q回Q否则返回最后一个表辑ּQ注意不一定是Boolean|Q?

&&是这栯的Q从W一个开始,遇到无意义的q回Q否则返回最后一个表辑ּQ注意同上)Q?

!是这栯的Q?/font> 对表辑ּ的值取非(注意不是对表辑ּQ?

什么是无意义呢Q如下六?0,null,undefined,"",false,NaN。除此,视ؓ有意义?

new Boolean(),new Boolean(false)是同一个东西,׃它是一个对象,故是有意义的Q但其gؓfalseQ所以,可以看ؓ“有意义的false”,所以结果ؓ最后一个表辑ּ的倹{?


Jaunt 2006-11-24 19:11 发表评论
]]>
վ֩ģ壺 ŮƵվ| ƬƵһ| þþƷ뾫Ʒר| aɻ߹ۿ| Ļ߹ۿ| 뿨ͨҰ| պƷƵһ| պٸѲ| Ʒþþþþ޾Ʒ| һ| һaƬػ߹ۿѿ һa | 92˾ƷƵ| 츾þþƷ| һƬ߹ۿ| һѹۿ| Ʒһ| þùһƬѹۿ| ߳ѿƬ| ޻ɫ߹ۿƵ| ޾ƷƷԲۿ| ŷƵһ| 99REþþƷﶼǾƷ| רһ·߶| ޵Ӱ߲| ޾Ʒ99߹ۿ| Ļ߲Ƶ | ޳AvƬɫҹ| ëƬ߹ۿ| վ߿| պƷר| Ƶվѹۿ| ѹۿƵ| | þþƷ޸| պƷһ| žŮվ| һһ60Ƶ| һƵǿŮ| 鴤һһgifƵ| AVպAVһ| ձѹۿ|