javascript ¶¯Ì¬²åÈëÐÐ ±í¸ñ²Ù×÷
<script>
var i = 0;
function insertTr(obj)
{
var tr1 = tb.insertRow(obj.rowIndex+1);
var td1 = tr1.insertCell();
td1.innerHTML = "newCell" + i;
i += 1;
}
</script>
<table id=tb>
<tr onclick="insertTr(this)">
<td>2</td>
</tr>
<tr onclick="insertTr(this)">
<td>1</td>
</tr>
</table>
±í¸ñ²Ù×÷Àà(Ìí¼Ó£¬É¾³ý£¬ÅÅÐò£¬ÉÏÒÆ£¬ÏÂÒÆ)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">*{font-size:14px}button{margin:3px}</style>
<script type="text/javascript">
var mytable=null,mytable2=null;
window.onload=function(){
mytable=new CTable("tbl",10);
mytable2=new CTable("tbl2",6);
}
Array.prototype.each=function(f){for(var i=0;i<this.length;i++) f(this[i],i,this)}
function $A(arrayLike){
for(var i=0,ret=[];i<arrayLike.length;i++) ret.push(arrayLike[i]);
return ret
}
Function.prototype.bind = function() {
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
}
function CTable(id,rows){
this.tbl=typeof(id)=="string"?document.getElementById(id):id;
if (rows && /^\d+$/.test(rows)) this.addrows(rows)
}
CTable.prototype={
addrows:func
Ïà¹ØÎĵµ£º
Èç¹ûÄú»¹Ã»ÓÐÔĶÁ¡¶JavaScriptµ÷ÊÔ¼¼ÇÉÖ®£º¿ìËÙ¶¨Î»¡·£¬½¨ÒéÏÈ¿´¿´ÄÇÆª¡£Ëµ²»¶¨£¬ÓÿìËÙ¶¨Î»¾ÍÄܽâ¾öÎÊÌâÁË£¬ºÇºÇ¡£Õâ´ÎÎÒ»á×ܽá¼Ç¼һ϶ϵãµ÷ÊԵıʼǣ¬Ï£ÍûÒ²¶Ô´ó¼ÒÓÐÓ㬻¶Ó²¹³ä½»Á÷£¡
Ê×ÏÈ£¬ÔÚ¸÷¸öä¯ÀÀÆ÷ÖУ¬¶Ïµãµ÷ÊÔÖ§³ÖµÄ×îºÃµÄµ±È»ÊÇFirefox£¬Firefox²»½ö¿ÉÒÔʹÓÃFirebugµ÷ÊÔÒ³Ãæjs½Å±¾£¬»¹¿ÉÒÔÓø߼¶µ÷ÊÔ¹¤¾ßÀ ......
ClosureÖÐÎÄ·ÒëΪ±Õ°ü.×ÖÃæÉÏÀ´Àí½â¾ÍÊÇ"·â±ÕµÄ°ü".(ÕâÊÇÒ»¾ä·Ï»°)
±Õ°üÊÇʲô?
ÊéÃæ½âÊÍΪ: Ëùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨ÁËÕâЩ±äÁ¿µÄ»·¾³µÄ±í´ïʽ£¨Í¨³£ÊÇÒ»¸öº¯Êý£©£¬Òò¶øÕâЩ±äÁ¿Ò²ÊǸñí´ïʽµÄÒ»²¿·Ö¡£
ÎÒÈÏΪ±Õ°ü¾ÍÊÇÄܹ»¶Á/дº¯ÊýÄÚ²¿µÄijЩ±äÁ¿µÄ×Óº¯Êý,²¢½«ÕâЩ±äÁ¿±£´æÔÚÄÚ´æÖÐ.
± ......
1. ¿Í»§¶Ë //Ö÷ÒªÕë¶Ô±¾µØIEä¯ÀÀÆ÷·ÃÎÊ
<script
language="javascript">
function FileExist()
{
var sfso=new
ActiveXObject("Scripting.FileSystemObject");
var fPath="[The path of the
file]";
if(sfso.FileExists(fP ......
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.clientWidth;
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.clientHeight;
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetWidth (°üÀ¨±ßÏߵĿí);
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetHeight (°üÀ¨±ßÏߵĿí);
ÍøÒ³ÕýÎÄÈ«ÎÄ¿í£ºdocument.body.scrollWidth;
ÍøÒ³ÕýÎÄÈ«Îĸߣºdocument.body.scrollHeight;
......
×Ô´Ó Google ÍÆ³öº¬ V8 JavaScript ÒýÇæµÄ Chrome ÒÔÀ´£¬¹«ÖÚ¶Ô JavaScript
ÒýÇæÖ´ÐÐЧÂʵÄθ¿ÚÓÖÒ»´Î±»Ìá¸ß£¬ÖÚ¶àä¯ÀÀÆ÷µÄ¿ª·¢ÕßÃǽʾ¡ÄÔÖÌáÉýËûÃÇµÄ JavaScript ÐÔÄÜ£¬Opera ×îеÄ10.50 °æµÄ Carakan
ÒýÇæ¾Ý³ÆÒѾ³¬¹ý V8£¬¶ø Firefox µÄ¿ª·¢ÕßÃÇÒ²²»¸ÊʾÈõ¡£
×î½üÉý¼¶µ½ Firefox 3.6 µÄÓû§ÒѾ·¢ÏÖËûÃÇµÄ Java ......