Search Results

Search found 541 results on 22 pages for 'settimeout'.

Page 2/22 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • JavaScript setTimeout setInterval within one function

    - by dagoof
    I think I might be overtired but I cannot for the life of me make sense of this, and I think it's due to a lack of knowledge of javascript var itv=function(){ return setInterval(function(){ sys.puts('interval'); }, 1000); } var tout=function(itv){ return setTimeout(function(){ sys.puts('timeout'); clearInterval(itv); }, 5500); } With these two functions I can call a=tout(itv()); and get a looping timer to run for 5.5 seconds and then exit, essentially. By my logic, this should work but it simply is not var dotime=function(){ return setTimeout(function(){ clearInterval(function(){ return setInterval(function(){ sys.puts("interval"); }, 1000); }); }, 5500); } any insight in this matter would be appreciated.

    Read the article

  • JS settimeout doesn’t work in IE8…

    - by Nagesh
    <html> <head> <script> var i; i = 0; function loop() { i = i + 1; alert(String(i)); setTimeout("loop()",1000); } setTimeout("loop()",1000); </script> </head> <body> </body> </html> Please try the above code in IE8 it will not give alert message for every 1 sec if you hold right click. But in firefox it will give alert message even though if you dont release the right click. I want the firefox functionality in IE8.

    Read the article

  • Javascript scope problem with object and setTimeout

    - by Shabbyrobe
    I'm trying to make a jQuery plugin that executes a method on a timer. I'd like it to work on multiple elements on a page independently. I've reached a point where the timer executes for each element, but the method called in the setTimeout seems to only know about the last instance of the plugin. I know I'm doing something fundamentally stupid here, but I'm danged if I know what. I know stuff like this has been asked 8 million times on here before, but I've not managed to find an answer that relates to my specific problem. Here's a script that demonstrates the structure of what I'm doing. <html> <head> <script type="text/javascript" src="assets/jquery.min.js"></script> <script type="text/javascript"> var crap = 0; (function($) { jQuery.fn.pants = function(options) { var trousers = { id: null, current: 0, waitTimeMs: 1000, begin: function() { var d = new Date(); this.id = crap++; console.log(this.id); // do a bunch of stuff window.setTimeout(function(self) {return function() {self.next();}}(this), this.waitTimeMs); }, next: function() { this.current ++; console.log(this.id); window.setTimeout(function(self) {return function() {self.next();}}(this), this.waitTimeMs); }, }; options = options || {}; $.extend(trousers, options); this.each(function(index, element) { trousers.begin(); }); return this; }; } )(jQuery); jQuery(document).ready(function() { jQuery("div.wahey").pants(); }); </script> </head> <body> <div class="wahey"></div> <div class="wahey"></div> </body> </html> The output I get is this: 0 1 1 1 1 1 The output I expect to get is this: 0 1 0 1 0 1

    Read the article

  • Javascript: setTimeout() - help needed

    - by ilkin
    Hi guys, I'm currently doing a highlighting function on a webpage and im using the jquery plugin for that. My code looks like this: var input = function() { var matchword = $('#searchbox').val(); if(matchword != "") { $('body').removeHighlight(); $('body').highlight($('#searchbox').val()); } } $(document).ready(function() { $('#searchbox').keyup(function() { setTimeout("input()", 2000); }); }); It works fine if there is not so large amount of data on the page. But in case of large amount of data on the page the whole process is slowing down which causes that inputbox is freezing untill the letter is hightlighted. So the typing is not smooth. I tryed to use a setTimeout but it seems doesnt help. Any ideas?

    Read the article

  • Hiding an error message div with setTimeout not working using Smarty

    - by Donald
    Hi guys, I'm trying to hide an error message div using a javascript function setTimeout after a specified time but it gives me errors that its a wrong smarty syntax, i've never used smarty before so i would really appreciate it if anyone can help me get up to speed with this syntax My code is as follows {if $error_message != ""} <script type="text/javascript"> setTimeout(function(){$('error').hide(); }, 1000); </script> <div id="error" class='error_message'> {$error_message} </div> {/if} Thanks in advance

    Read the article

  • javascript setTimeout function out of scope.

    - by Keyo
    I am trying to call showUpload(); from within two setTimeouts. Neither works. It seems to be out of scope and I'm not sure why. I tried this.showUpload() which didn't work either. $(document).ready(function(){ var progress_key = $('#progress_key').val(); // this sets up the progress bar $('#uploadform').submit(function() { setTimeout("showUpload()",1500); $("#progressbar").progressbar({ value:0}).fadeIn(); }); // uses ajax to poll the uploadprogress.php page with the id // deserializes the json string, and computes the percentage (integer) // update the jQuery progress bar // sets a timer for the next poll in 750ms function showUpload() { $.get("/myid/videos/uploadprogress/" + progress_key, function(data) { if (!data) return; var response; eval ("response = " + data); if (!response) return; var percentage = Math.floor(100 * parseInt(response['bytes_uploaded']) / parseInt(response['bytes_total'])); $("#progressbar").progressbar({ value:percentage}) }); setTimeout("showUpload()", 750); } }); Thank you for your time.

    Read the article

  • Set z-index with javascript setTimeout()

    - by user2266261
    What I'm trying to do is to have 4 expandable divs overlapping each other with transition set in css for 0.6s. Because the expanding lasts for 0.6s I'd like to have the expanded div lose it's higher z-index after it's done collapsing, otherwise it looks silly. However, it doesn't work, the z-index remains unchanged. It's probably somethings stupid, but I just can't find it. Thanks! <div class="wrapper" style="position: relative;"> <div id="one" style="position: absolute;" onmouseover=" this.style.height='250px'; this.style.zIndex='1'; " onmouseout=" this.style.height='50px'; setTimeout(function() {this.style.zIndex='0';},600); ">blahblahblahblah</div> <div id="two" style="position: absolute;" onmouseover=" this.style.height='250px'; this.style.zIndex='1'; " onmouseout=" this.style.height='50px'; setTimeout(function() {this.style.zIndex='0';},600); ">blahblahblahblah</div> </div>

    Read the article

  • setTimeout stack over flow..

    - by user344862
    Untitled 1 $(document).ready(function(){ counterFN(); var theCounter = 1; function counterFN() { $(".searchInput").val(theCounter); theCounter++; setTimeout(counterFN(),1000); } }); </script> </head> <body> <input type="text" class="searchInput" /> </body>

    Read the article

  • setTimeout not working in windows script (jscript)

    - by Sibo Lin
    When I try to run the following code in my program setTimeout("alert('moo')", 1000); I get the following error Error: Object expected Code: 800A138F Source: Microsoft JScript runtime error Why? Am I calling the wrong function? What I want to do is delay the execution of the subsequent function.

    Read the article

  • jquery timout funcation not work properly

    - by 3gwebtrain
    HI, i ma using the settimeout function to display block and append to 'li', once the mouseover. and i just want to remove the block and make it none. in my funcation works fine. but problem is even just my mouse cross the li, it self the block getting visibile. how to avoid this? my code is: var thisLi; var storedTimeoutID; $("ul.redwood-user li,ul.user-list li").live("mouseover", function(){ thisLi = $(this); var needShow = thisLi.children('a.copier-link'); if($(needShow).is(':hidden')){ storedTimeoutID = setTimeout(function(){$(thisLi).children('a.copier-link').appendTo(thisLi).show();},3000); } else{ storedTimeoutID = setTimeout(function(){$(thisLi).siblings().children('a.copier-link').appendTo(thisLi).show();},3000); } }); $("ul.redwood-user li,ul.user-list li").live("mouseleave", function(){ clearTimeout(storedTimeoutID); //$('ul.redwood-user li').children('a.copier-link').hide(); $('ul.user-list li').children('a.copier-link').hide(); });

    Read the article

  • Equivalent to window.setTimeout() for C++

    - by bobobobo
    In javascript there's this sweet, sweet function window.setTimeout( func, 1000 ) ; which will asynchronously invoke func after 1000 ms. I want to do something similar in C++ (without multithreading), so I put together a sample loop like: #include <stdio.h> struct Callback { // The _time_ this function will be executed. double execTime ; // The function to execute after execTime has passed void* func ; } ; // Sample function to execute void go() { puts( "GO" ) ; } // Global program-wide sense of time double time ; int main() { // start the timer time = 0 ; // Make a sample callback Callback c1 ; c1.execTime = 10000 ; c1.func = go ; while( 1 ) { // its time to execute it if( time c1.execTime ) { c1.func ; // !! doesn't work! } time++; } } How can I make something like this work?

    Read the article

  • Thoughts on a Shoutbox anyone?

    - by sologhost
    I'm wanting to create a shoutbox, though I'm wondering if there is another way to go about this rather than using setInterval to query the database for new shouts every number of seconds. Honestly, I don't like having to go about it this way. Seems a bit redundant and repetitive and just plain old wrong. Not to mention the blinking of the shouts as it grabs the data. So I'm wondering on how the professionals do this? I mean, I've seen shoutboxes that work surperb and doesn't seem to be using any setInterval or setTimeout javascript functions to do this. Can anyone suggest any ideas or an approach to this that doesn't use setInterval or setTimeout?? Thanks :)

    Read the article

  • Javascript doesnt update

    - by Trikam
    Hi all, I have a function that passes a parameter which is a function call and then i use setTimeout to call this passed function call. now i tried two methods with setTimout to raise the event and i used function.call(). When this passed parameter function call was raised none of the javascript was being updated, below is the javascript which im using to raise the event and the javascript which is supposed to be updated: The function being passed is [context] - function() { ErrorMessageFileSelect('diverrortextchoosechannal','The file chosen is to big, you must choose a file less than 1MB'); } function FileSizeOnLoad(contentLength,context) { if (context != null) { // context.call(); setTimeout(context,0); // or context.call(); } else { $('#inputHiddenFileSizeField').val(contentLength); DisplayChoseFileInformation(contentLength); } } //this is where the update should happen function ErrorMessageFileSelect(className, errorMessage) { $('div.' + className).text(errorMessage); alert($('div.' + className).text()); } Is there somthing im missing, can someone help me with this issue please. Thanks

    Read the article

  • [jscript] Good (better) substition for setInterval or setTimeout

    - by riffnl
    I've got a masterpage with some nice UI (jQuery) features. One of these options is interefering with my embedded YouTube (or other alike-) objects. On each, in this case, setInterval event the embedded video stops displaying new frames (for like a second). More detail: I've got a "polaroid" gallery (in the header) with only 5 100x100 images in it (test: preloading has no effect on performance) and my gallery will show or hide them (fade-in / fade-out) after a period of time. (test: non-animated display:hide or display:block has no effect on performance). After some testing and I've come to the conclusion that it isn't the "animated" showing or hiding of the pictures, but it's the interval itself (- since altering to display:hide or block had the same result). Perhaps it is my "gallery" "function" on itself ... function poladroid() { if (!galleryHasFocus) { if (galleryMax >= 0) { galleryCurrent++; if (galleryCurrent > galleryMax) { galleryCurrent = 0; showPictures = !showPictures; } if (showPictures) { $('#pic-' + galleryCurrent.toString()).show("slow"); } else { $('#pic-' + galleryCurrent.toString()).hide("slow"); } } } if (!intervalSet) { window.setInterval("poladroid()", 3000); intervalSet = true; } } It's not like my function is doing really awkward stuff is it? So, I was thinking I needed a more "loose" interval function.. but is there an option for it?

    Read the article

  • setInterval By the minute On the minute

    - by bushman
    To the javascript enthusiasts, how would you program a setTimeOut (or setInterval) handle to fire by the minute on the minute. So for example, if it is the 51 second of the current time, then fire it in 8 seconds, if it is the 14th second then fire it in 46 seconds thanks

    Read the article

  • clearTimeout not working in javascript autocomplete script

    - by Travis
    I am using the following code as part of an autocomplete script to avoid hammering the server with every keystroke: var that = this; textInput.bind("keyup", function() { clearTimeout(that.timer); that.timer = setTimeout (that.doStuff(), 2000); }); Unfortunately, this does not clear the old timers. They still all execute. Does anyone know what I'm missing? Thanks!

    Read the article

  • How to delay hiding of a menu with Jquery Dropdown Menu?

    - by Keith Donegan
    I have a dropdown menu that works fine, but I would like it so, that if I hover off the menu, it doesn't immediately hide again. So basically I would like a one second delay. I have read about setTimeout, but not sure if it is what I need? $('#mainnav a').bind('mouseover', function() { $(this).parents('li').children('ul').show(); }); $('#mainnav a').bind('mouseout', function() { $(this).parents('li').children('ul').hide(); });

    Read the article

  • Detecting extended mousedown event on iPhone

    - by Alan Neal
    I want to detect an extended mousedown. The following code works in Firefox and Safari... var mousedownTimeout; $('#testButton').mousedown(function(){ mousedownTimeout = window.setTimeout(function(){ alert("Hey, let go."); }, 2000); }); $('#testButton').mouseup(function(){ window.clearTimeout(mousedownTimeout); }); ... but not on the iPhone because (quoting quirksmore.org)... The iPhone fires the mousedown, mouseup and click events in the correct order on a click (tap), but it either fires all three or none at all. Is there a way around this?

    Read the article

  • odd behavior setting timeouts inside a function with global references in javascript

    - by Pablo
    Here is the the function and the globals: $note_instance = Array(); $note_count = 0; function create(text){ count = $note_count++; time = 5000; $note_instance[count] = $notifications.notify("create", text); setTimeout(function(){ $note_instance[count].close() }, time); } The function simply opens a notification, a sets a timeout to close it in 5 seconds. so if i call this create("Good Note 1"); create("Good Note 2"); create("Good Note 3"); Ecah note should close 5 seconds from their creation, however always and only the last note closes, in this case "Good Note 3". Each note object has its own entry in the the $note_instance global array so the timeouts should no be overwriting themselves. What am i missing here folks? Thanks in advance

    Read the article

  • javascript accordion - tracking time question

    - by JohnMerlino
    Hey all, I was reading up on this javascript tutorial: http://www.switchonthecode.com/tutor...ccordion-menus Basically, it shows you how to create an accordion using pure javascript, not jquery. All made sense to me until the actual part of tracking the animation. He says "Because of all that, the first thing we do in the animation function is figure out how much time has passed since the last animation iteration." And then uses this code: Code: var elapsedTicks = curTick - lastTick; lastTick is equal to the value of when the function was called (Date().getTime()) and curTick is equal to the value when the function was received. I don't understand why we are subtracting one from the other right here. I can't imagine that there's any noticeable time difference between these two values. Or maybe I'm missing something. Is that animate() function only called once every time a menu title is clicked or is it called several times to create the incremental animation effect? setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" + openAccordion + "','" + nID + "')", 33); Thanks for any response.

    Read the article

  • Wait for function to finish before starting again.

    - by Matthew Brown
    Good Morning, I am trying to call the same function everytime the user presses a button. Here is what happens at the moment.. User clicks button - Calls function - function takes 1000ms+ to finish (due to animation with jQuery and AJAX calls) What I want to happen is every time the user presses the button it adds the function to the queue, waits for the previous call to finish, and then starts.. Is this possible? Sorry if my explanation is a bit confusing.. Thanks Matthew

    Read the article

  • Javascript timers

    - by resopollution
    I'm starting on a javascript MMORPG that will actually work smoothly. Currently, I created a demo to prove that I can move characters around and have them chat with each other, as well as see eachother move around live. http://set.rentfox.net/ Now Javascript timers are something I have not used extensively, but from what I know, correct me if I'm wrong, is that having multiple setIntervals happening at the same time doesn't really work well b/c it's all on a single thread. Lets say I wanted to have 10 different people nuking fireballs at a monster by using sprite background positioning with setInterval -- that animation would require 10 setIntervals doing repainting of the DOM for sprite background-position shifts. Wouldn't that be a big buggy? I was wondering if there was a way around all this, perhaps using Canvas, so that animations can all happen concurrently without creating an event queue and I don't have to worry about timers. Hope that makes sense, and please let me know if I need to clarify further.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >