I'm trying to build the framework for an AJAX back/forward button fixer. Basically it uses the hash fix for them (using text after the # to add history objects). To this effect, the function to check for updates has to be run every second or so. No problem, I'll just use setInterval for that.
For whatever reason, though, setInterval gives me an error. Specifically that oldLocation (global variable) is undefined (in the checkURL function). So I try setTimeout. Same thing. When I just call the function explicitly once (adding checkURL(); to the end of the script) everything works wonderfuly; it's just setting it up on a timer that messes up. Frankly, I've no idea why it's doing this. (The bug just seems so odd) Maybe a more advanced JS coder can shed some light on it.. Code:
I have a script that I have tried running using both setTimeout and setInterval. It works fine in every browser except safari 3. It will run fine for a few loops and then stop.
I've been trying a number of different approaches but can't seem to get it right. The idea was to loop the main funtion of the script (loadContent) by ending with the setTimeout, that I had to move to another function. Why, I don't know, but that's the only way it works. I'm a professional PHP programmer, getting to grips with Javascript in this era where Ajax rules firmly is part of my job. Can't say I have been enjoying the experience so far, though.Right, enough bashing for today! The idea was to have a simple script, linked to a php script that would load images, based on the data sent via Javascript and an XML datafile. This does happen, only: the timeout of 5 or 6 seconds doesn't seem to last even a millisecond.
I wanna get some deep information about how browser implements the dispatch mechanism of events , native setTimeout and setInterval. Any books or articles reference it?
I have the following function that's supposed to say "Please make a guess" 20 seconds after an initial confirmation is displayed. However, it's immediately displayed as soon as someone hits "Cancel". If I change it's time to 40000 (20 seconds after the initial function is called), it does do it 40 seconds total, so it kind of does what I want. So it seems that the second setTimeout is initiated from the time the script is called generally, but I'm looking for a way specifically to have the 20 seconds start only after the "cancel" button is hit.
when I call obj.loop(); 'this' in obj.next refers to setInterval and not obj . I realise I can add var ref = this; and send it with setInterval but is there something I can do to get 'this' to refer to obj when in obj.next?
I'm attempting to create a small function that when called upon will change the CSS background property 10 times at 80 millisecond intervals. I'm pretty sure setInterval() is the way to go about this, but I've been toying with my script for an hour and can't get anything to work.
At each 80 millisecond interval, the CSS background property should change like so:
I would normally just use the background-position property, but it seems the hyphen throws javascript for a slip. It's really not necessary for this function, but if there's a way to use hyphens, it would be good to know for future reference.
So this works ok in the sense that the animation is performed smoothly. But to my understanding it should expand the height of the box 1pixel every 1ms, so it should expand very quickly from the base height to the maxHeight limit, but I click on the link and it animates soooooo slooooowly -- smoothly, i mean, but it takes well over a minute to expand to the full height. I just need to speed the damn thing up! Also, if i change "box.heightCount++;" to "box.heightCount+=1;" it gets all messed up. What am I missing here?
i'm scratching my head over achieving similar results with setInterval() function, and how I can keep it from looping infinitely.
I want to do something like this: var i = 0; var endTime = now + ((1000*60)*2); // 2 minutes after now while (now <=endTime) { i = i + 1; now = new Date().getTime(); } document.write("total iterations: " + i);
however you can't do this because of lag issues, so i'll settle for using setinterval on its smallest interval of a millisecond, here is my attempt to translate the above to a setinterval solution: var endTime = now + ((1000*60)*2); // 2 minutes after now var intervalID = setInterval(loopFunc(endTime),1); function loopFunc(endTime,intervalID) { if (new Date().getTime() <= endTime) { i = i + 1; } else { clearInterval(intervalID); }}
as you can see I have prolbems figuring out how to stop the interval from continuing to iterate, and passing the interval id, I'm clueless Also I'm clueless on echoing the total iterations via this method.
is not working correct. doSomething is not known. i think, setInterval is not inside the class, so doSomething is private and unknown for the interval.
I've developed a plugin for a simple slide show. and here is the code [URL] The problem is when I mouse over the pic, the console error logs: "slideSwitch is not defined" The same error would still happen if I define function slideSwitch(){} and call
Inside of $(document).ready(function () I have: var refre****= setInterval(function(){ $('#mydiv').load("mypage.htm"); }, 9000); This is working great in IE, it loads mypage.htm into mydiv every 9 seconds. If I change the contents of mypage.htm I can see it in mydiv after 9 seconds with IE, but not with Firefox. With Firefox I can see the reloading symbol on top of the tab every 9 seconds, but I don't see the page changed.
I am new in web development. I think this problem is related to javascript, I have write script which will change images after 2sec, through setInterval function. Script is as follows.
<script> var images = new Array ("img/1.jpg", "img/2.jpg", "img/3.jpg"); var currentIndex = 0; function Start(){ setInterval("ChangeImage()", 2000); }function ChangeImage(){ currentIndex++; if(currentIndex == images.length){ currentIndex = 0; } document.images[0].src = images[currentIndex]; } </script>
But when I place in img tag which is in third row div and reload page, these series of images show in first row div. It does not show where I have specified area for it in css.
First row div: <div id="menu"> <img src="header/menu.png" name="menuImg"/> </div> My series of images show in this div when I load page.
I just encountered a rather strange issue with setInterval() in Firefox. Take for example this code:
function test(){ setInterval("window.status+='x'", 1000) }
test() test()
So I call test() twice, which should mean the status bar gets appended 2x's every second. This is the case in IE6 and Opera, but in Firefox, it pauses every 2 seconds, and adds 4x's each time. Basically, Firefox seem to not update every second but every 2 seconds as a result. Anyone know what's going on?
function load(cv) { setInterval("checknew('cv')",1000); } checknew sends the number 1 or 0 depending on what load sends, and in turn, its just alternating 1/0 every second.
I am unsure how to send the number I get in load(cv) to checknew(cv) every 1 second on setInterval.
I am trying to use the variable "theObject" to pass a value to setInterval. But I keep getting the error that "theObject" is not defined. But I have tested it with an "alert" just before the "if" statement and I know that not only is it defined, but it has the correct value.
Why won't setInterval recognise the variable? Is there a way to get this to work?
I tried putting the method in setInterval in quotations, which runs continuously but it won't allow me to pass parameters so in turn it does nothing. The way I have it now passes parameters but doesn't run continuously.
$('#icon' + i).bind('click', function() { var icon = this.id; var iconID = setInterval(iconExpand(icon),5); }); function iconExpand(obj) { var mLeft = $('#' + obj).css('margin-left'); var mTop = $('#' + obj).css('margin-top'); [Code]....
I'm calling `setInterval(myfunc, 100);`. That function receives one parameter which seems to be -3, 0, 3, 6 or 9. This isn't a problem, but I'm wondering what it is. Does someone know?
Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
In the code below there is a set interval. The interval works perfect. There also is a clearInterval, this one works aswell. When I click on the button with the ID sluitinfonew the interval should be set again, this also works. But offcourse the clearInterval doesn't work anymore because the var is within the function(i'm not sure). Is there a better way to do this? I can't get it to work.[code]
I was trying to use a jQuery timer to repeat a function at intervals, but it didn't work in IE. Then I read that IE doesn't support setInterval, which seems amazing. Did I read this right? And if so, what do I use in jQuery to keep repeating a function at intervals? I've tried a few things and they all bomb out in IE, just doing something once, although they work in FF. What works in the execrable IE and real browsers?