顺便问下
<body onload="dosome();">
<form id="Form1" method="post" runat="server"> <table width="564" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td id="t1" width="564" height="17" > </td>
</tr>
<tr>
<td id="t2" height="22" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t3" height="24" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t4" height="22" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t5" height="75"> </td>
</tr>
</table>
</form>
我想在 body 的 onload 里 alert <td id="t4"〉的 id 怎么做
<body onload="dosome();">
<form id="Form1" method="post" runat="server"> <table width="564" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td id="t1" width="564" height="17" > </td>
</tr>
<tr>
<td id="t2" height="22" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t3" height="24" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t4" height="22" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t5" height="75"> </td>
</tr>
</table>
</form>
我想在 body 的 onload 里 alert <td id="t4"〉的 id 怎么做
这个方法在上个帖子已经说过了,是fason为setTimeout函数执行的时候给函数添加加对象的方法
我在下面给他注释下吧
首先要弄明白call
和apply方法
call的方法中有无数个参数,第一个参数是哪个对象调用方法,之后的参数就是向该方法中传递的对象序列
比如
a.call(b,"1","2")相当于正常使用的b.a("1","2");
apply方法稍微有些不同,只是把后面的参数序列改成一个对象也就是一个数组<script language="javascript">
var _st = window.setInterval;//定义一个对象,让他等于原来的window.setInterval的function对象,以保持重载之后的方法和原来的一致。
window.setInterval = function(fRef,mDelay)//重新定义window.setInterval函数
{
if(typeof fRef =="function")//判断第一个参数是不是function对象,如果不是则返回,是继续
{
var argu=Array.prototype.slice.call(arguments,2);//截取所有参数中的前两个,也就是正常情况下向window.setInterval函数中传的参数,即一个函数名,一个间隔的时间
var f=(//定义新的函数,并且把多传的那个参数也传给正常情况下要执行的函数
function(){
fRef.apply(null, argu);//执行该函数
}
);
return _st(f,mDelay);//返回新的重载好的函数
}
return _st(fRef,mDelay);
}
<body onload="alert(document.getElementById('t4').id)">
<form id="Form1" method="post" runat="server"> <table width="564" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td id="t1" width="564" height="17" > </td>
</tr>
<tr>
<td id="t2" height="22" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t3" height="24" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t4" height="22" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td id="t5" height="75"> </td>
</tr>
</table>
</form>