473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

setInterval argument problem (Internet Explorer)

Expand|Select|Wrap|Line Numbers
  1.  
  2. checkWin = function(x)
  3.     {
  4.     alert(x);    // Displays undefined
  5.     }
  6.  
  7.  
  8.  
  9. function startScroll(e)
  10. {
  11.     if ( TimeOutID == null)
  12.     {
  13.     var x = e.clientX;
  14.             alert(x);//displays correct X value
  15.      TimeOutID = window.setInterval(checkWin,100,x);    
  16.     }
  17. }
  18.  
  19.  
I am having trouble with the setInterval function for Internet Explorer. When I send in the variable x through the setInterval function i keep getting undefined in the function being called.

I am assuming its some scope issue..?
Nov 11 '07 #1
2 6588
Dasty
101 Expert 100+
The only mistake you are doing is, that you assume that setInterval provides more then 2 parameters. Yes, additional parameters are supported in some browsers, but as you can see far from all :D

The solution are closures for you. (works everywhere)

[PHP]function startScroll(e)
{
if ( TimeOutID == null)
{
var local_x = e.clientX;
var local_function= function() { alert(local_x) };
TimeOutID = window.setInterval(local_function,100);
}
}

[/PHP]

Hope that helps.
Nov 11 '07 #2
Nice, closure functions! Thanks for your assist~
Nov 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Richard A. DeVenezia | last post by:
Is some future Mozilla going to support setInterval ( <function:function>, <interval:number> ) ? Right now it seems to be simply setInterval ( <function-text:string>, <interval:number> ) --...
1
by: Weston C | last post by:
In the course of trying to build a simple clock, I've run into a problem using the setInterval (and setTimeout) function. http://weston.canncentral.org/misc/tkeep/tkeep.html...
17
by: George Hester | last post by:
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...
6
by: marktm | last post by:
Hi- I am trying to use setInterval to call a method within an object and have not had any luck. I get "Object doesn't support this property or method" when I execute the following code. What I...
2
by: Jim Red | last post by:
hello, how can i set an interval inside a class exmpl. var Class = (function() { var interval = undefined; function initInterval(instance) { interval = setInterval("doSomething", 1000,...
3
by: shawn | last post by:
Hi All Was trying to get this bit of code working (simplified of course) for (i=0;i<uuid_num;i++) { window.setInterval(InitMap(uuidValues), timePeriod); } Where uuid_num, uuidValues,...
8
by: derrickn | last post by:
Having a problem with setTimeout("doSomething()", 5000) or, preferably, setInterval("doSomething()",5000), referring to a function: doSomething() { // do something here } -- where the do...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
1
by: Jeff | last post by:
I've been trying to pass in an object in a setInterval but it complains about missing ] after elenment list. setInterval("someFunction("+some_object+")",1000); What's the correct syntax to do...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.