的setInterval(F(X)); [英] setInterval(F(x));

查看:96
本文介绍了的setInterval(F(X));的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用setInterval,其参数是一个也有参数的函数吗?例如,我有一个函数更改(Msg),其中Msg是动态生成的,此时不返回任何内容(除了我猜之外)。我想有setInterval(change(Msg));但那不行。有什么建议?谢谢。


-

George Hester

__________________________________

解决方案

2004年7月29日星期四20:02:31 +0000,George Hester写道:

我可以使用setInterval,其参数是一个函数,它也是<有争论吗?例如,我有一个函数更改(Msg),其中Msg是动态生成的,并且此时不返回任何内容(除了真实的
我猜)。我想有setInterval(change(Msg));但那
不起作用。有什么建议?谢谢。




你打电话给谁'锄头?!?!


用PHP封装的JavaScript:


print(" setInterval(\" GetTime(document.getElementBy Id(''\" + TimeAnchor.id

+ \"'' ))\",1000);");


让我看看我是否可以为你剥离PHP:


setInterval(" GetTime(document.getElementById(''+ TimeAnchor.id +'')),

1000);");


使用setInterval调用函数并将参数传递给该函数。

-

im

美国爱国者法案是最不爱国的行为美国历史。


除了笨拙的数字之外没有人。


我试过了。我没有工作。让我更具体一点:


Msg =" 1< div> 2< div> 3< div> 4< div> 5< div> 6"


change()只是更改页面中div的可见性状态。当Msg =时然后div被隐藏了。当Msg<>"" div是可见的。


所以我这样做了:


setInterval(" change(''+ Msg +'');" );我相信你拥有的。首先,字符串连接看起来不正确,所以我可以理解为什么它不起作用。我确实尝试过setInterval(" change(" + Msg +")");但也没有好处。谢谢。


-

George Hester

__________________________________

Ivan Marsh <一个***** @ you.now>在留言新闻中写道:pa ************************** @ you.now ...

On Thu, 2004年7月29日20:02:31 +0000,George Hester写道:

我可以使用setInterval,其参数是一个也有参数的函数吗?例如,我有一个函数更改(Msg),其中Msg是动态生成的,并且此时不返回任何内容(除了真实的
我猜)。我想有setInterval(change(Msg));但那
不起作用。有什么建议?谢谢。



你打电话给'锄头的人?!?!

用PHP封装的JavaScript:

print(" setInterval(\" GetTime(document.getElementBy Id(''\" + TimeAnchor.id
+ \"''))\",1000);");

让我看看能否为你剥离PHP:

setInterval(" GetTime(document.getElementById(''+ TimeAnchor.id +'')),
1000);");

使用setInterval调用函数并将参数传递给该函数。


-
im
美国爱国者法案是美国历史上最不爱国的行为。



George Hester写道:

没有人除了我笨拙的数字。

我试过了。我没有工作。让我不具体:

Msg =" 1< div> 2< div> 3< div> 4< div> 5< div> 6"

更改( )只是更改页面中div的可见性状态。
当Msg =""然后div被隐藏了。当Msg<>""那么div是可见的。
所以我做了这个:
setInterval(" change(''+ Msg +'');");我相信你拥有的东西。
首先,字符串连接看起来不正确,所以我可以理解为什么它不起作用。我确实尝试过setInterval(" change(" + Msg +")");
但也不好。谢谢。




如果您正在检查Msg的状态,那么让更改功能执行此操作。


功能更改(){

if(Msg!=""){

// Msg不是空的,相应地采取行动

}

else {

//消息是空的,相应的行为

}

}


Hoe can I use setInterval where its argument is a function which also has an argument? For example I have a function change(Msg) where Msg is dynamically generated and returns nothing at this point (other than true I guess). I would like to have setInterval(change(Msg)); but that doesn''t work. Any suggestions? Thanks.

--
George Hester
__________________________________

解决方案

On Thu, 29 Jul 2004 20:02:31 +0000, George Hester wrote:

Hoe can I use setInterval where its argument is a function which also
has an argument? For example I have a function change(Msg) where Msg is
dynamically generated and returns nothing at this point (other than true
I guess). I would like to have setInterval(change(Msg)); but that
doesn''t work. Any suggestions? Thanks.



Who you callin'' a hoe?!?!

JavaScript encapsulated in PHP:

print("setInterval(\"GetTime(document.getElementBy Id(''\" + TimeAnchor.id
+\"''))\", 1000);");

Let me see if I can strip out the PHP for you:

setInterval("GetTime(document.getElementById('' + TimeAnchor.id +'')),
1000);");

Calls a function with setInterval and passes an argument to that function.
--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.


No one except my clumsy digits.

I tried it. I didn''t work. Let me be nore specific:

Msg = "1<div>2<div>3<div>4<div>5<div>6"

change() just changes the visibility status of a div in the page. When Msg="" then the div is hidden. When Msg<>"" then the div is visible.

So I did this:

setInterval("change(''+Msg+'');"); which I believe is what you had. First the string concatenation doesn''t look right and so I can understand why it doesn''t work. I did try setInterval("change("+Msg+")"); but no good also. Thanks though.

--
George Hester
__________________________________
"Ivan Marsh" <an*****@you.now> wrote in message news:pa**************************@you.now...

On Thu, 29 Jul 2004 20:02:31 +0000, George Hester wrote:

Hoe can I use setInterval where its argument is a function which also
has an argument? For example I have a function change(Msg) where Msg is
dynamically generated and returns nothing at this point (other than true
I guess). I would like to have setInterval(change(Msg)); but that
doesn''t work. Any suggestions? Thanks.



Who you callin'' a hoe?!?!

JavaScript encapsulated in PHP:

print("setInterval(\"GetTime(document.getElementBy Id(''\" + TimeAnchor.id
+\"''))\", 1000);");

Let me see if I can strip out the PHP for you:

setInterval("GetTime(document.getElementById('' + TimeAnchor.id +'')),
1000);");

Calls a function with setInterval and passes an argument to that function.


--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.



George Hester wrote:

No one except my clumsy digits.

I tried it. I didn''t work. Let me be nore specific:

Msg = "1<div>2<div>3<div>4<div>5<div>6"
change() just changes the visibility status of a div in the page.
When Msg="" then the div is hidden. When Msg<>"" then the div is visible.
So I did this:
setInterval("change(''+Msg+'');"); which I believe is what you had.
First the string concatenation doesn''t look right and so I can
understand why it doesn''t work. I did try setInterval("change("+Msg+")");
but no good also. Thanks though.



If you are checking the status of Msg, then let the change function do it.

function change(){
if (Msg != ""){
//Msg isn''t empty, act accordingly
}
else{
//Msg is empty, act accordingly
}
}


这篇关于的setInterval(F(X));的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆