jscript怎样传递obj?????在线求教,紧急求助!!!!!!!!! setTimeout 默认是不能 调用带参数的函数的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果要这样做, 你在这里搜一下 fason 的帖子 你可以用一个页面级全局变量呀!!<script>var global=null;function test(obj){ if(obj) global = obj; else obj = global; setTimeout("test()",1000/2);}</script><input type=button value="test_obj" name="test_obj" onclick="test(test_obj)"> 好多内容,在哪里面有呀setTimeout 函数只是举个例子 多谢,meizz(梅花雪) ,这个办法我也想过,可是如果函数较多比较麻烦有办法时间传递吗 可以传递参数,不可以传递对象,你可以传递 test_obj.namefunction test(objname){ //alert(document.all(objname)); //test1(document.all(objname)); //ok setTimeout("test('"+objname+"')",1000/2); //error}function test1(obj){ alert(obj);}</script><input type=button value="test_obj" name="test_obj" onclick="test(test_obj.name)"> <script>var _st = window.setTimeout;window.setTimeout = function(fRef, mDelay) { if(typeof fRef == 'function'){ var argu = Array.prototype.slice.call(arguments,2); var f = (function(){ fRef.apply(null, argu); }); return _st(f, mDelay); } return _st(fRef,mDelay);}function test(x){ alert(x);}window.setTimeout(test,1000,'fason');</script>这个是阿信的,不过好象没用 直接传递的方法有是有, 不过有点麻烦, 你可以对 setTimeout 此类的系统函数进行重载, 让它可以接受更多的参数, 这种例子 fason 写了一个你可以参考参考:var _st = window.setTimeout;window.setTimeout = function(fRef, param){ if(typeof(fRef)== 'function') { var argu = Array.prototype.slice.call(arguments,2); var func = (function(){ fRef.apply(null, argu); }); return _st(func, param); } return _st(fRef,mDelay);}setTimeout("test()", 500, obj); //这个obj会作为test()函数的参数使用 <script>function test(obj){ alert(obj); //test1(obj); //ok setTimeout("test("+obj.uniqueID+")",1000/2); //error}function test1(obj){ alert(obj);}</script><input type=button value="test_obj" name="test_obj" onclick="test(test_obj)"> IE8窗口怎么关闭啊 急急急求解:怎样获取iframe点击事件 求助贴:关于scrollTop的兼容性问题 window.open()方法问题 怎样获取div内div的名字? 怎样移动文本框的焦点到末尾? 关于iframe加载的问题,急,请指教 初始话问题,急,帮忙看看 100分求这样的导航条 一直没有办法解决,有A.htm和B.htm二个页面,在A上打开B,能否在B页面上刷新A页面。 如何用javascript 調用API的 Beep()函數? Checkbox的问题
<script>
var global=null;
function test(obj)
{
if(obj) global = obj;
else obj = global;
setTimeout("test()",1000/2);
}
</script>
<input type=button value="test_obj" name="test_obj" onclick="test(test_obj)">
setTimeout 函数只是举个例子
{
//alert(document.all(objname));
//test1(document.all(objname)); //ok
setTimeout("test('"+objname+"')",1000/2); //error}
function test1(obj)
{
alert(obj);
}
</script>
<input type=button value="test_obj" name="test_obj" onclick="test(test_obj.name)">
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == 'function'){
var argu = Array.prototype.slice.call(arguments,2);
var f = (function(){ fRef.apply(null, argu); });
return _st(f, mDelay);
}
return _st(fRef,mDelay);
}function test(x){
alert(x);
}
window.setTimeout(test,1000,'fason');
</script>这个是阿信的,不过好象没用
window.setTimeout = function(fRef, param)
{
if(typeof(fRef)== 'function')
{
var argu = Array.prototype.slice.call(arguments,2);
var func = (function(){ fRef.apply(null, argu); });
return _st(func, param);
}
return _st(fRef,mDelay);
}
setTimeout("test()", 500, obj); //这个obj会作为test()函数的参数使用
function test(obj)
{
alert(obj);
//test1(obj); //ok
setTimeout("test("+obj.uniqueID+")",1000/2); //error}
function test1(obj)
{
alert(obj);
}
</script>
<input type=button value="test_obj" name="test_obj" onclick="test(test_obj)">