开发者

Settimeout function in Firefox does not seem to work

Is there a way to make the following work?

f开发者_C百科unction TimerEvent()
{

      TIMER_OBJ = setTimeout('Ajaxsessioncheck();', '<%=Timer%>');

}

I am calling this function in the onload event but it is not calling the Ajaxsessioncheck function when the time has elapsed in Firefox. In IE and Chrome it works fine.

thanks for all for ur time.. i changed the code as sent timer as integer now i have a different problem. In the Ajaxsessioncheck() function i wil call a JSP page from i am not getting Response in Firefox.


You've specified '<%=Timer%>' as a string (denoted by the single quotes), where it should be an integer, like so: <%=Timer%>

You should also specify the first argument as a function reference rather than a string, so your final output would be:

setTimeout(Ajaxsessioncheck, <%=Timer%>);


you shouldn't pass the second parameter as string.

   TIMER_OBJ = setTimeout('Ajaxsessioncheck();', <%=Timer%>);

should work fine. but to be even more correct, you should also avoid passing the first parameter as string, because otherwise is gets evaluated - a hidden execution of eval happens, and eval is evil. therefore, this is what you want:

   TIMER_OBJ = setTimeout(Ajaxsessioncheck, <%=Timer%>);

PS. declaring a variable without using keyword var causes it to leak to the global scope. I'm not sure if you're aware of this fact.


'<%=Timer%>' is a string - it should be an int in milliseconds.

Almost all questions starting with X does not work in Y comes down to differences in browser implementation. Similar to document.getElementById does not work in firefox and the element has a name but no ID. Works in IE but not in Fx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜