JavaScript - Set Interval
Hi All:
I've created an array to randomly display multiple images/links in js. [CODE] function disp_links(number) { for (i=1;i<=number;i++) { var k = Math.floor(Math.random()*links.length); document.write(links[k]); setInterval((function (n) { return function () { disp_links(n); }; })(number), 5000); } } After the interval the image/links changes, but the rest of the site disappears. I think my problem is the document.write(). But I don't know how to use DOM to manipulate the current page without replacing it, Can anyone help? Similar TutorialsIm trying to make a function/object that acts like setInterval(). One major differance being is i can change the interval rate at any given time. I have an example below: Code: <script type='text/javascript'> window.setVariableInterval = function(callbackFunc, timing){ var variableInterval = { firstInterval: timing, interval: timing, callback: callbackFunc, clear: "", // placeHolder: function(){ return setInterval(function(){if(this.interval == timing.toString()) {variableInterval.callback.call(variableInterval);}}, timing)} placeHolder: function(){return variableInterval.clear = setInterval( function(){ if(variableInterval.interval == variableInterval.firstInterval){ variableInterval.callback.call(variableInterval); }else{ clearInterval(variableInterval.clear); variableInterval.firstInterval = variableInterval.interval; variableInterval.placeHolder(); } }, variableInterval.interval) } } return variableInterval.placeHolder(); } var test = 1; var that = setVariableInterval(function(){test++; document.getElementById('test').innerHTML = test+ " - " +this.interval+ " - " +this.firstInterval}, 1); Just for as a test script I made a script that counts up continusly and slows down as it does it. my problem is i can seem to get accesses to the instance interval. i tired: variableInterval.interval that.interval that.variableInterval.interval all of them show up as undefined. any one know why? I want to run a javascript that loads after 2 seconds. So first it have to say loading and then the javascript must run. How can i do this? guys help me in this.. see this code http://userscripts.org/scripts/show/118593 wall attack in this code is just awsum.. bt i need 1 min interval between each post.. can u plz help me out in this |