Search Results

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

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

  • Javascript Cookie problems IE

    - by blakey87
    Hi guys, been bagging my head over some Javascript, please help, I cant see why it simply wont find my cookie in IE 7 or 8 I am setting the cookie true through another event, but I just want to see IE pick up the cookie which I initially set. Works in firefox too, thanks in advance. var t=setTimeout("doAlert()",8000); var doAlertVar = true; document.cookie = "closed=0;expires=0;path="; function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie; alert(ca); ca = ca.replace(/^\s*|\s*$/g,''); ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function doAlert(){ if(readCookie('closed')==1){ doAlertVar = false; } if(readCookie('closed')==0){ alert("unlicensed demo version\nbuy online at"); } t=setTimeout("doAlert()",5000); }

    Read the article

  • javascript watching for variable change via a timer

    - by DA
    I have a slide show where every 10 seconds the next image loads. Once an image loads, it waits 10 seconds (setTimeout) and then calls a function which fades it out, then calls the function again to fade in the next image. It repeats indefinitely. This works. However, at times, I'm going to want to over-ride this "function1 call - pause - function2 call - function1 call" loop outside of this function (for instance, I may click on a slide # and want to jump directly to that slide and cancel the current pause). One solution seems to be to set up a variable, allow other events to change that variable and then in my original function chain, check for any changes before continuing the loop. I have this set up: var ping = 500; var pausetime = 10000; for(i=0; i<=pausetime; i=i+ping){ setTimeout(function(){ console.log(gocheckthevariable()); console.log(i); pseudoIf('the variable is true AND the timer is done then...do the next thing') },i) } The idea is that I'd like to pause for 10 seconds. During this pause, every half second I'll check to see if this should be stopped. The above will write out to the console the following every half second: true 10000 true 10000 true 10000 etc... But what I want/need is this: true 0 true 500 true 1000 etc... The basic problem is that the for loop executes before each of the set timeouts. While I can check the value of the variable every half second, I can't match that against the current loop index. I'm sure this is a common issue, but I'm at a loss what I should actually be searching for.

    Read the article

  • Controller actions appear to be synchronous though on different requests?

    - by Oded
    I am under the impression that the below code should work asynchronously. However, when I am looking at firebug, I see the requests fired asynchronously, but the results coming back synchronously: Controller: [HandleError] public class HomeController : Controller { public ActionResult Status() { return Content(Session["status"].ToString()); } public ActionResult CreateSite() { Session["status"] += "Starting new site creation"; Thread.Sleep(20000); // Simulate long running task Session["status"] += "<br />New site creation complete"; return Content(string.Empty); } } Javascript/jQuery: $(document).ready(function () { $.ajax({ url: '/home/CreateSite', async: true, success: function () { mynamespace.done = true; } }); setTimeout(mynamespace.getStatus, 2000); }); var mynamespace = { counter: 0, done: false, getStatus: function () { $('#console').append('.'); if (mynamespace.counter == 4) { mynamespace.counter = 0; $.ajax({ url: '/home/Status', success: function (data) { $('#console').html(data); } }); } if (!mynamespace.done) { mynamespace.counter++; setTimeout(mynamespace.getStatus, 500); } } } Addtional information: IIS 7.0 Windows 2008 R2 Server Running in a VMWare virutual machine Can anyone explain this? Shouldn't the Status action be returning practically immediately instead of waiting for CreateSite to finish? Edit: How can I get the long running process to kick off and still get status updates?

    Read the article

  • Determining selected state of jQuery Buttons

    - by lloydphillips
    I've got two radio buttons in a .net page which are being transformed to jQuery buttons a la http://jqueryui.com/demos/button/#radio When the page is loaded I have button 2 as checked. When clicking the buttons I'm firing the postback event. Problem is you can click on that button that is selected by default on the initial load i.e. Button 2, the postback is fired but the event handler isn't called in the .net code behind because the radio button is already classed as selected (and in normal circumstances wouldn't allow the postback to fire). To get around this I've added the e.PreventDefault() method BUT this is causing issues when Button 1 is clicked because before the click handler is called the button is set to selected. Therefore, in every case in the following code e.PreventDefault() is called: $(document).ready(function(){ $("[id*='rbPayable']").click(function(e){ if ($("[id*='rbPayable']").attr("checked")) e.preventDefault(); else setTimeout('__doPostBack(\'this.id\',\'\')', 0) }) $("[id*='rbReceivable']").click(function(e){ if ($("[id*='rbReceivable']").attr("checked")) e.preventDefault(); else setTimeout('__doPostBack(\'this.id\',\'\')', 0) }) }); What is the best way for me to load the page and effectively be able to do the following: 'If rbReceivable is checked then don't do anything otherwise do a postback.'

    Read the article

  • Slideshow in Javascript without framework, animation?

    - by aaron
    The issue I am having is fairly complicated to explain. I have written up a javascript that displays an image slideshow, and it works fairly well, despite using up more resources than I would like // imgArr[] is populated before var i = 0; var pageLoaded = 0; window.onload = function() {pageLoaded = 1;} function loaded(i,f) { if (document.getElementById(i) != null) f(); else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100); } } function displaySlideshow() { document.getElementById(destinationId).innerHTML = '<div id="slideWindow"><img src="'+imgArr[i]+'" />' + '<img src="'+imgArr[i + 1]+'" /></div>'; setTimeout('displaySlideshow()',1000*3); i++; if (i >= imgArr.length - 1) i = 0; } loaded(destinationId,displaySlideshow); So, this script dynamically adds two images to a HTML element, and it is wrapped in a div. The div is styled with the height and width of the image, with the overflow (the second image) hidden. The second image is below the first, and the slideshow is meant to go from RIGHT to LEFT. My inquiry is twofold: 1) Is there a more efficient way of doing this? 2) How would I animate the images? Would I need to put the second image on the right of the first with CSS somehow, and then set a timer to pull the images (via a style) leftward?

    Read the article

  • JavaScript sleep

    - by Diazath
    yes, i know - that question has thousands of answers. please, don't tell me about "setTimeout" method becasuse - yes, everything is possible with that but not so easy as using sleep() method. for example: function fibonacci(n) { console.log("Computing Fibonacci for " + n + "..."); var result = 0; //wait 1 second before computing for lower n sleep(1000); result = (n <= 1) ? 1 : (fibonacci(n - 1) + fibonacci(n - 2)); //wait 1 second before announcing the result sleep(1000); console.log("F(" + n + ") = " + result); return result; } if you know how to get the same result using setTimeout - tell me ;) fibanacci is pretty easy task, because there not more than 2 recursions, but how about n-recursions (like fib(1) + fib(2) + .. + fib(n) and sleep after every "+"? nah, sleep would be muuuuuch easier. but still i can't get working example of implementing it. while (curr - start < time) { curr = (...) } is tricky, but it won't work (just stops my browser and then throw all console.logs at once).

    Read the article

  • Making firefox refresh images faster

    - by Earlz
    I have a thing I'm doing where I need a webpage to stream a series of images from the local client computer. I have a very simple run here: http://jsbin.com/idowi/34 The code is extremely simple setTimeout ( "refreshImage()", 100 ); function refreshImage(){ var date = new Date() var ticks = date.getTime() $('#image').attr('src','http://127.0.0.1:2723/signature?'+ticks.toString()); setTimeout ("refreshImage()", 100 ); } Basically I have a signature pad being used on the client machine. We want for the signature to show up in the web page and for them to see themselves signing it within the web page(the pad does not have an LCD to show it to them right there). So I setup a simple local HTTP server which grabs an image of what the current state of the signature pad looks like and it gets sent to the browser. This has no problems in any browser(tested in IE7, 8, and Chrome) but Firefox where it is extremely laggy and jumpy and doesn't keep with the 10 FPS rate. Does anyone have any ideas on how to fix this? I've tried creating very simple double buffering in javascript but that just made things worse. Also for a bit more information it seems that Firefox is executing the javascript at the correct framerate as on the server the requests are coming in at a constant speed. But the images are only refreshed inconsistently ranging from 5 times per second all the way down to 0 times per second(taking 2 seconds to do a refresh) Also I have tried using different image formats all with the same results. The formats I've tried include bitmaps, PNGs, and GIFs (GIFs caused a minor problem in Chrome with flicker though) Could it be possible that Firefox is somehow caching my images causing a slight lag? I send these headers though: Pragma-directive: no-cache Cache-directive: no-cache Cache-control: no-cache Pragma: no-cache Expires: 0

    Read the article

  • Background loading javascript into iframe with using jQuery/Ajax?

    - by user210099
    I'm working on an offline only help system which requires loading a large amount of search-related data into an iframe before the search functionality can be used. Due to the folder structure of the project, I am unable to use Ajax-related background load methods, since the files I need are loaded a few directories "up and over." I have written some code which delays the loading of the help data until the rest of the webpage is loaded. The help data consists of a bunch of javascript files which have information about the terms, ect that exist in the help books which are installed on the system. The webpage works fine, until I start to load this help data into a hidden iframe. While the javascript files are loading, I can not use any of the webpage. Links that require a small files be downloaded for hover over effects don't show up, javascript (switching tabs on the page) has no effect. I'm wondering if this is just a limitation of the way javascript works, or if there's something else going on here. Once all the files are loaded for the help system, the webpage works as expected. function test(){ var MGCFrame = eval("parent.parent"); if((ALLFRAMESLOADED == true)){ t2 = MGCFrame.setTimeout("this.IHHeader.frames[0].loadData()",1); } else{ t1 = MGCFrame.setTimeout("this.IHHeader.frames[0].test()",1000); } } Load data simply starts the data loading process. Thanks for any help you can provide.

    Read the article

  • Why is my long polling code for a notification system not updating in real time? PHP MYSQL

    - by tjones
    I am making a notification system similar to the red notification on facebook. It should update the number of messages sent to a user in real time. When the message MYSQL table is updated, it should instantly notify the user, but it does not. There does not seem to be an error inserting into MYSQL because on page refresh the notifications update just fine. I am essentially using code from this video tutorial: http://www.screenr.com/SNH (which updates in realtime if a data.txt file is changed, but it is not written for MYSQL like I am trying to do) Is there something wrong with the below code: **Javascript** <script type="text/javascript"> $(document).ready(function(){ var timestamp = null; function waitForMsg(){ $.ajax({ type: "GET", url: "getData.php", data: "userid=" + userid, async: true, cache: false, success: function(data){ var json = eval('(' + data + ')'); if (json['msg'] != "") { $('.notification').fadeIn().html(json['msg']); } setTimeout('waitForMsg()',30000); }, error: function(XMLHttpRequest, textStatus, errorThrown){ setTimeout('waitForMsg()',30000); } }); } waitForMsg(); </script> <body> <div class="notification"></div> **PHP*** <?php if ($_SERVER['REQUEST_METHOD'] == 'GET' ) { $userid = $_GET['userid']; include("config.php"); $sql="SELECT MAX(time) FROM notification WHERE userid='$userid'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $currentmodif = $row['MAX(time)']; $s="SELECT MAX(lasttimeread) FROM notificationsRead WHERE submittedby='$userid'"; $r = mysql_query($s); $rows = mysql_fetch_assoc($r); $lasttimeread = $rows['MAX(lasttimeread)']; while ($currentmodif <= $lasttimeread) { usleep(10000); clearstatcache(); $currentmodif = $row['MAX(time)']; } $response = array(); $response['msg'] = You have new messages; echo json_encode($response); } ?>

    Read the article

  • Background loading javascript into iframe without using jQuery/Ajax?

    - by user210099
    I'm working on an offline only help system which requires loading a large amount of search-related data into an iframe before the search functionality can be used. Due to the folder structure of the project, I am unable to use Ajax-related background load methods, since the files I need are loaded a few directories "up and over." I have written some code which delays the loading of the help data until the rest of the webpage is loaded. The help data consists of a bunch of javascript files which have information about the terms, ect that exist in the help books which are installed on the system. The webpage works fine, until I start to load this help data into a hidden iframe. While the javascript files are loading, I can not use any of the webpage. Links that require a small files be downloaded for hover over effects don't show up, javascript (switching tabs on the page) has no effect. I'm wondering if this is just a limitation of the way javascript works, or if there's something else going on here. Once all the files are loaded for the help system, the webpage works as expected. function test(){ var MGCFrame = eval("parent.parent"); if((ALLFRAMESLOADED == true)){ t2 = MGCFrame.setTimeout("this.IHHeader.frames[0].loadData()",1); } else{ t1 = MGCFrame.setTimeout("this.IHHeader.frames[0].test()",1000); } } Load data simply starts the data loading process. Thanks for any help you can provide.

    Read the article

  • What is the proper way to wait a script loaded completely before another

    - by FatDogMark
    I am making a website that is divided by several sections <div id='section-1' class='section'>web content</div> <div id='section-2' class='section'>web content</div> I have like ten sections on my webpage ,each sections height is set to the user window height when document is ready by javascript $('.section').height($(window).height()); Some effects like slideshows on my webpage require the calculated height of the section in order to work properly. Therefore I always use something like this at document ready as a solution. setTimeout(startslideshow,1000); setTimeout(startanimations,1000); ...etc To make sure the section height is the user window height before the slideshow's code start because the sections cannot change to user window height instantly once the webpage loaded will generate serious problems in my slideshow code,like wrong calculated positions. Therefore there will be a situation that's after the page loaded, there will be about a second everything is messed up,before everything can works properly, how could I avoid that being seen by the user? I tried to $(document).hide(),or $('html,body').hide(), then fade in after a second,but I get other weird problems, especially on ipad,my fixed position top navigation bar will always become 'not fixed' while user is scrolling. As I am a self-learner, I afraid my method is not typical. I want to know what is the common ways of real web programmers usually do when they have to divide his webpage into different sections and set its height to window height , then make sure the other effects that's depends on the section height works properly and avoid to wait the height change for a second?

    Read the article

  • Basic Ajax Cache Issue

    - by michaelespinosa
    I have a single page that I need to on occasion asynchronously check the server to see if the status of the page is current (basically, Live or Offline). You will see I have a function with a var live that is set when the page initially loads. I then do an ajax request to the server to retrieve whether the status of live is true or false. I compare the initial live variable with the newly returned data json object. If they're the same I do nothing, but if there different I apply some css classes. I recursively run it with setTimeout (Is there a better way to recursively do this?). My Problem: data.live doesn't change from it's initial time it runs even when it has changed in the db. I know my mysql is working because it returs the right value on the initial load. It seems like a caching issue. Any help is greatly appreciated. function checkLive() { var live = <?=$result["live"]?>; $.ajax({ type: 'get', url: '/live/live.php', dataType: 'json', success: function(data) { console.log('checking for updates... current:' + data.live); if (data.live == live) { return; } else { var elems = $('div.player_meta, object, h3.offline_message'); if (data.live == '1') { elems.removeClass('offline').addClass('live'); } else { elems.addClass('live').addClass('offline'); } } } }); setTimeout(function() { checkLive() } ,15000); } checkLive();

    Read the article

  • Async run for javascript by using listeners

    - by CharlieShi
    I have two functions, the names are Function3, Function4, Function3 will send request to server side to get jsondata by using ajax, which, however, will take about 3 seconds to complete. Function4 is a common function which will wait for Function3's result and then action. My code puts below: function ajaxRequest(container) { $.ajax({ url: "Home/GetResult", type: "post", success: function (data) { container.append(data.message); } }); } var eventable = { on: function (event, cb) { $(this).on(event, cb); }, trigger: function (event) { $(this).trigger(event); } } var Function3 = { run: function () { var self = this; setTimeout(function () { ajaxRequest($(".container1")); self.trigger('done'); }, 500); } } var Function4 = { run: function () { var self = this; setTimeout(function () { $(".container1").append("Function4 complete"); self.trigger('done'); },500); } } $.extend(Function3, eventable); $.extend(Function4, eventable); Function3.on('done', function (event) { Function4.run(); }); Function4.on('done', function () { $(".container1").append("All done"); }); Function3.run(); but now the problem is, when I start the code , it always show me the result as : first will appear "Function4 complete", then "All done" follows, 3 seconds later, "Function3 complete" will appear. That's out of my expection because my expection is "Function3 complete" comes first, "Function4 complete" comes second and "All done" is expected as the last one. Anyone can help me on this? thx in advice. EDIT: I have included all the functions above now. Also, you can check the js script in JSFIDDER: http://jsfiddle.net/sporto/FYBjc/light/ I have replaced the function in JSFIDDER from a common array push action to ajax request.

    Read the article

  • jquery hover not working properly other than IE6

    - by Kranthi
    Hi All, We developed navigation bar using jQuery 1.4.2. Functionality is to show submneus for different menu items when user hovers on it. It is working perfectly in IE6 but we see some weird problems in other browsers. In Firefox, when the page gets loaded, it works fine but when we hit f5, the submenu wont appear on hover. To get submenu we need to click on any other menu item. In Chrome, its the same to add on, some time even we click on any menu item, and hover submenu wont show up. In Safari, nothing shows up most of the times, but on clicking 5-6 menu items, submenu is shown.When we see loading text in safari it shows the submenu. but on every click the loading text wont appear.. We are very much confused..is it the browser behavior/code/jquery?? Below is the snippet: Html: <ul> <li><a class="mainLinks" href="google.com">Support</a> <ul><li>Sublink1</li></ul> </ul> Html code is absolutely fine. Jquery: var timeout = null; var ie = (document.all) ? true : false; $(document).ready(function(){ var $mainLink = null; var $subLink = null; $(".mainLinks").each(function(){ if ($(this).hasClass("current")) { $(this).mouseout(function() { var $this = $(this); timeout = setTimeout(function() { $(".popUpNav", $this.parent()).css({ visibility : 'hidden' }); $('.popUpArrow').hide(); ieCompat('show'); }, 200); }); } else { $(this).hover(function() { reset(); ieCompat('hide'); // Saving this for later use in the popUpNav hover event $mainLink = $(this); $popUpNav = $(".popUpNav", $mainLink.parent()); // Default width is width of one column var popupWidth = $('.popUpNavSection').width() + 20; // Calculate popup width depending on the number of columns var numColumns = $popUpNav.find('.popUpNavSection').length; if (numColumns != 0) { popupWidth *= numColumns; } var elPos = $mainLink.position(); var leftOffset = 0; if (elPos.left + popupWidth > 950) { leftOffset = elPos.left + popupWidth - 948; } $popUpNav.css({ top : elPos.top + 31 + 'px', left : elPos.left - leftOffset + 'px', visibility : 'visible', width : popupWidth + 'px' }); $('.popUpArrow').css({ left : elPos.left + Math.round(($mainLink.width() / 2)) + 20 + 'px', top : '27px' }).show(); }, function() { var $this = $(this); timeout = setTimeout(function() { $(".popUpNav", $this.parent()).css({ visibility : 'hidden' }); $('.popUpArrow').hide() ieCompat('show'); }, 200); } ); } }); $(".subLinks").hover( function(e) { $subLink = $(this); var elPos = $subLink.position(); var popupWidth = $(".popUpNavLv2",$subLink.parent()).width(); var leftOffset = 0; ieCompat('hide'); $(".popUpNavLv2",$subLink.parent()).css({ top : elPos.top + 32 + 'px', left : elPos.left - leftOffset + 'px', visibility : 'visible' }); }, function() { var $this = $(this); timeout = setTimeout(function() { $(".popUpNavLv2", $this.parent()).css({ visibility : 'hidden' }); }, 200); ieCompat('show'); } ); $('.popUpNav').hover( function() { clearTimeout(timeout); $mainLink.addClass('current'); $(this).css('visibility', 'visible'); $('.popUpArrow').show(); }, function() { $mainLink.removeClass('current'); $(this).css('visibility', 'hidden'); $('.popUpArrow').hide(); ieCompat('show'); } ); $('.popUpNavLv2').hover( function() { clearTimeout(timeout); $(this).css('visibility', 'visible'); ieCompat('hide'); }, function() { ieCompat('show'); $(this).css('visibility', 'hidden'); } ); // If on mac, reduce left padding on the tabs if (/mac os x/.test(navigator.userAgent.toLowerCase())) { $('.mainLinks, .mainLinksHome').css('padding-left', '23px'); } }); Thanks a lot in advance for looking into it. Thanks | Kranthi

    Read the article

  • Fading in/Fade out text in IE

    - by tau
    I had a problem and whipped up a quick solution: fade-in and fade-out a series of quotations. My solution works just as I want it in every browser except any of the IEs. The only problem with the IEs is that the text does not fade in and fade out; the text simply pops into existence. I believe I've run into a similar problem before when trying to dynamically change the filter:alpha(opacity=xx) of an element. Any help is greatly appreciated! <html> <head> <style> .fadetext{ background:green; border:1px solid red; height:50px; width:500px; } .fadetext div{ background:yellow; } </style> <script type="text/javascript"> var CI_common = { C:function(cls,elm){ if(!elm) elm = document; if(document.getElementsByClassName){ return elm.getElementsByClassName(cls); }else{ var t = []; var o = elm.getElementsByTagName("*"); var r = new RegExp("(^|\\s)" + cls + "($|\\s)"); for(var i=0;i<o.length;i++){ if(o[i].className.match(r)) t.push(o[i]); } return t; } }, eventAdd:function(obj,evt,func){ if(obj.addEventListener){ obj.addEventListener(evt,func,false); }else if(obj.attachEvent){ obj["x" + evt + func] = func; obj[evt + func] = function(){ obj["x" + evt + func](window.event); } obj.attachEvent("on" + evt,obj[evt + func]); } } } var CI_fadetext = { init:function(){ var c = CI_common.C("fadetext"); // Simply a getElementsByClassName function for(var i=0;i<c.length;i++){ c[i].style.overflow = "hidden"; var kids = c[i].getElementsByTagName("div"); for(var j=0;j<kids.length;j++){ kids[j].style.display = "none"; kids[j].style.filter = "alpha(opacity=0)"; kids[j].style.opacity = "0"; (function(obj,index,len){ obj.fadetexttimeout = setTimeout(function(){ CI_fadetext.fade(obj,true); obj.fadeininterval = setInterval(function(){ CI_fadetext.fade(obj,true); },5000*len) },5000*index); setTimeout(function(){ CI_fadetext.fade(obj,false); obj.fadeoutinterval = setInterval(function(){ CI_fadetext.fade(obj,false); },5000*len) },5000*index+4400); })(kids[j],j,kids.length); } } }, fade:function(elm,dir){ function fade(start){ start = (dir ? start + 10 : start - 10); elm.style.filter = "alpha(opacity=" + start + ")"; elm.style.opacity = start/100; document.getElementById("output").innerHTML = elm.style.filter; if(start > 100 || start <0){ elm.style.display = (dir ? "" : "none"); elm.style.filter = "alpha(opacity=" + (dir ? 100 : 0) + ")"; elm.style.opacity = (dir ? 1 : 0); }else elm.fadetexttimeout = setTimeout(function(){fade(start);},50); } if(dir){ elm.style.display = ""; fade(0); }else fade(100); } } CI_common.eventAdd(window,"load",CI_fadetext.init); // Just a window.onload level 2 event listener </script> </head> <body> <div id="output"></div> <div class="fadetext"> <div>AAAA</div> <div>BBBB</div> <div>CCCC</div> <div>DDDD</div> <div>EEEE</div> </div> </body> </html>

    Read the article

  • Possible to manipulate UI elements via dispatchEvent()?

    - by rinogo
    Hi all! I'm trying to manually dispatch events on a textfield so I can manipulate it indirectly via code (e.g. place cursor at a given set of x/y coordinates). However, my events seem to have no effect. I've written a test to experiment with this phenomenon: package sandbox { import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFieldType; import flash.text.TextFieldAutoSize; import flash.utils.setTimeout; public class Test extends Sprite { private var tf:TextField; private var tf2:TextField; public function Test() { super(); tf = new TextField(); tf.text = 'Interact here'; tf.type = TextFieldType.INPUT; addChild(tf); tf2 = new TextField(); tf2.text = 'Same events replayed with five second delay here'; tf2.autoSize = TextFieldAutoSize.LEFT; tf2.type = TextFieldType.INPUT; tf2.y = 30; addChild(tf2); tf.addEventListener(MouseEvent.CLICK, mouseListener); tf.addEventListener(MouseEvent.DOUBLE_CLICK, mouseListener); tf.addEventListener(MouseEvent.MOUSE_DOWN, mouseListener); tf.addEventListener(MouseEvent.MOUSE_MOVE, mouseListener); tf.addEventListener(MouseEvent.MOUSE_OUT, mouseListener); tf.addEventListener(MouseEvent.MOUSE_OVER, mouseListener); tf.addEventListener(MouseEvent.MOUSE_UP, mouseListener); tf.addEventListener(MouseEvent.MOUSE_WHEEL, mouseListener); tf.addEventListener(MouseEvent.ROLL_OUT, mouseListener); tf.addEventListener(MouseEvent.ROLL_OVER, mouseListener); } private function mouseListener(event:MouseEvent):void { //trace(event); setTimeout(function():void {trace(event); tf2.dispatchEvent(event);}, 5000); } } } Essentially, all this test does is to use setTimeout to effectively 'record' events on TextField tf and replay them five seconds later on TextField tf2. When an event is dispatched on tf2, it is traced to the console output. The console output upon running this program and clicking on tf is: [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=0 localY=1 stageX=0 stageY=1 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="rollOver" bubbles=false cancelable=false eventPhase=2 localX=0 localY=1 stageX=0 stageY=1 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseOver" bubbles=true cancelable=false eventPhase=3 localX=0 localY=1 stageX=0 stageY=1 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=2 localY=1 stageX=2 stageY=1 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=2 localY=2 stageX=2 stageY=2 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=2 localY=3 stageX=2 stageY=3 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=3 localY=3 stageX=3 stageY=3 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=5 localY=3 stageX=5 stageY=3 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=6 localY=5 stageX=6 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=7 localY=5 stageX=7 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=9 localY=5 stageX=9 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=10 localY=5 stageX=10 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=11 localY=5 stageX=11 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=12 localY=5 stageX=12 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseDown" bubbles=true cancelable=false eventPhase=3 localX=12 localY=5 stageX=12 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseUp" bubbles=true cancelable=false eventPhase=3 localX=12 localY=5 stageX=12 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="click" bubbles=true cancelable=false eventPhase=3 localX=12 localY=5 stageX=12 stageY=5 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=10 localY=4 stageX=10 stageY=4 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=9 localY=2 stageX=9 stageY=2 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=3 localX=9 localY=1 stageX=9 stageY=1 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="mouseOut" bubbles=true cancelable=false eventPhase=3 localX=-1 localY=-1 stageX=-1 stageY=-1 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] [MouseEvent type="rollOut" bubbles=false cancelable=false eventPhase=2 localX=-1 localY=-1 stageX=-1 stageY=-1 relatedObject=null ctrlKey=false altKey=false shiftKey=false delta=0] As we can see, the events are being captured and replayed successfully. However, no change occurs in tf2 - the mouse cursor does not appear in tf2 as we would expect. In fact, the cursor remains in tf even after the tf2 events are dispatched. Please help! Thanks, -Rich

    Read the article

  • Is there an alternative to javascript for the web that can do multi-threading and synchronous execution?

    - by rambodash
    I would like to program web applications as I do with desktop programming languages, where the code is synchronously executed and browser doesn't freeze when doing loops. Yes I know there are workarounds using callbacks and setTimeout, but they are all workarounds after all and they don't give the same flexibility when programming in the orthodox way I've been looking at Dart as a possibilty, but I can't seem to find where it says it can do either of these. The same with haxe, emscript, and the hundreds of other converters that try to circumvent javascript. In the end it gets converted to Javascript so you ultimately have to be conscious about asynchronous/multi threading.

    Read the article

  • Strange javascript error when using Kongregates API

    - by Phil
    In the hopes of finding a fellow unity3d developer also aiming for the Kongregate contest.. I've implemented the Kongregate API and can see that the game receives a call with my username and presents it ingame. I'm using Application.ExternalCall("kongregate.stats.submit",type,amount); where type is a string "Best Score" and amount is an int (1000 or something). This is the error I'm getting: You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround. callASFunction:function(a,b){if(FABrid...tion, can be used as a workaround."); I'm wondering, has anyone else had this error or am I somehow doing something stupid? Thanks!

    Read the article

  • Google's Opinion on Javascript Page Refresh

    - by user35306
    I was wondering if anyone knows Google's view on this. My company has a homepage that features a lot of 3rd parties on it and it needs to inform customers which ones are currently online, which aren't, and which are currently busy. Because this constantly changes, we have the homepage refresh to show the most relevant and up-to-date content to our users. I'm not using a meta refresh element in the http-equiv parameter to do this. Instead I have this js element to refresh the page: window.setTimeout("refreshPage()", 120000); I just want to know whether people think Google might consider this a violation of the content guidelines or not. Or if it's not an outright violation, then at least if Google frowns on this or not. It doesn't redirect the user to a different page or anything, just refreshes the page so that they can see the most relevant content.

    Read the article

  • jqGrid Filter Toolbar initial default value

    - by Paul Creasey
    I'm using jqGrid with the filter toolbar, i need to set an initial default filter value to one of the fields so that only rows with status 'Open' are displayed by default, but the user can display Closed rows if desired. At the moment i have a workaround like this setTimeout(function() {$('#gs_Status').val('Open');$("#eventsGrid")[0].triggerToolbar()},500); but it results in a second request and is pretty bad really. Does anybody know how to do this?

    Read the article

  • Memory leak involving jQuery Ajax requests

    - by Eli Courtwright
    I have a webpage that's leaking memory in both IE8 and Firefox; the memory usage displayed in the Windows Process Explorer just keeps growing over time. The following page requests the "unplanned.json" url, which is a static file that never changes (though I do set my Cache-control HTTP header to no-cache to make sure that the Ajax request always goes through). When it gets the results, it clears out an HTML table, loops over the json array it got back from the server, and dynamically adds a row to an HTML table for each entry in the array. Then it waits 2 seconds and repeats this process. Here's the entire webpage: <html> <head> <title>Test Page</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> </head> <body> <script type="text/javascript"> function kickoff() { $.getJSON("unplanned.json", resetTable); } function resetTable(rows) { $("#content tbody").empty(); for(var i=0; i<rows.length; i++) { $("<tr>" + "<td>" + rows[i].mpe_name + "</td>" + "<td>" + rows[i].bin + "</td>" + "<td>" + rows[i].request_time + "</td>" + "<td>" + rows[i].filtered_delta + "</td>" + "<td>" + rows[i].failed_delta + "</td>" + "</tr>").appendTo("#content tbody"); } setTimeout(kickoff, 2000); } $(kickoff); </script> <table id="content" border="1" style="width:100% ; text-align:center"> <thead><tr> <th>MPE</th> <th>Bin</th> <th>When</th> <th>Filtered</th> <th>Failed</th> </tr></thead> <tbody></tbody> </table> </body> </html> If it helps, here's an example of the json I'm sending back (it's this exact array wuith thousands of entries instead of just one): [ { mpe_name: "DBOSS-995", request_time: "09/18/2009 11:51:06", bin: 4, filtered_delta: 1, failed_delta: 1 } ] EDIT: I've accepted Toran's extremely helpful answer, but I feel I should post some additional code, since his removefromdom jQuery plugin has some limitations: It only removes individual elements. So you can't give it a query like `$("#content tbody tr")` and expect it to remove all of the elements you've specified. Any element that you remove with it must have an `id` attribute. So if I want to remove my `tbody`, then I must assign an `id` to my `tbody` tag or else it will give an error. It removes the element itself and all of its descendants, so if you simply want to empty that element then you'll have to re-create it afterwards (or modify the plugin to empty instead of remove). So here's my page above modified to use Toran's plugin. For the sake of simplicity I didn't apply any of the general performance advice offered by Peter. Here's the page which now no longer memory leaks: <html> <head> <title>Test Page</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> </head> <body> <script type="text/javascript"> <!-- $.fn.removefromdom = function(s) { if (!this) return; var el = document.getElementById(this.attr("id")); if (!el) return; var bin = document.getElementById("IELeakGarbageBin"); //before deleting el, recursively delete all of its children. while (el.childNodes.length > 0) { if (!bin) { bin = document.createElement("DIV"); bin.id = "IELeakGarbageBin"; document.body.appendChild(bin); } bin.appendChild(el.childNodes[el.childNodes.length - 1]); bin.innerHTML = ""; } el.parentNode.removeChild(el); if (!bin) { bin = document.createElement("DIV"); bin.id = "IELeakGarbageBin"; document.body.appendChild(bin); } bin.appendChild(el); bin.innerHTML = ""; }; var resets = 0; function kickoff() { $.getJSON("unplanned.json", resetTable); } function resetTable(rows) { $("#content tbody").removefromdom(); $("#content").append('<tbody id="id_field_required"></tbody>'); for(var i=0; i<rows.length; i++) { $("#content tbody").append("<tr><td>" + rows[i].mpe_name + "</td>" + "<td>" + rows[i].bin + "</td>" + "<td>" + rows[i].request_time + "</td>" + "<td>" + rows[i].filtered_delta + "</td>" + "<td>" + rows[i].failed_delta + "</td></tr>"); } resets++; $("#message").html("Content set this many times: " + resets); setTimeout(kickoff, 2000); } $(kickoff); // --> </script> <div id="message" style="color:red"></div> <table id="content" border="1" style="width:100% ; text-align:center"> <thead><tr> <th>MPE</th> <th>Bin</th> <th>When</th> <th>Filtered</th> <th>Failed</th> </tr></thead> <tbody id="id_field_required"></tbody> </table> </body> </html> FURTHER EDIT: I'll leave my question unchanged, though it's worth noting that this memory leak has nothing to do with Ajax. In fact, the following code would memory leak just the same and be just as easily solved with Toran's removefromdom jQuery plugin: function resetTable() { $("#content tbody").empty(); for(var i=0; i<1000; i++) { $("#content tbody").append("<tr><td>" + "DBOSS-095" + "</td>" + "<td>" + 4 + "</td>" + "<td>" + "09/18/2009 11:51:06" + "</td>" + "<td>" + 1 + "</td>" + "<td>" + 1 + "</td></tr>"); } setTimeout(resetTable, 2000); } $(resetTable);

    Read the article

  • How do I prevent the concurrent execution of a javascript function?

    - by RyanV
    I am making a ticker similar to the "From the AP" one at The Huffington Post, using jQuery. The ticker rotates through a ul, either by user command (clicking an arrow) or by an auto-scroll. Each list-item is display:none by default. It is revealed by the addition of a "showHeadline" class which is display:list-item. HTML for the UL Looks like this: <ul class="news" id="news"> <li class="tickerTitle showHeadline">Test Entry</li> <li class="tickerTitle">Test Entry2</li> <li class="tickerTitle">Test Entry3</li> </ul> When the user clicks the right arrow, or the auto-scroll setTimeout goes off, it runs a tickForward() function: function tickForward(){ var $active = $('#news li.showHeadline'); var $next = $active.next(); if($next.length==0) $next = $('#news li:first'); $active.stop(true, true); $active.fadeOut('slow', function() {$active.removeClass('showHeadline');}); setTimeout(function(){$next.fadeIn('slow', function(){$next.addClass('showHeadline');})}, 1000); if(isPaused == true){ } else{ startScroll() } }; This is heavily inspired by Jon Raasch's A Simple jQuery Slideshow. Basically, find what's visible, what should be visible next, make the visible thing fade and remove the class that marks it as visible, then fade in the next thing and add the class that makes it visible. Now, everything is hunky-dory if the auto-scroll is running, kicking off tickForward() once every three seconds. But if the user clicks the arrow button repeatedly, it creates two negative conditions: Rather than advance quickly through the list for just the number of clicks made, it continues scrolling at a faster-than-normal rate indefinitely. It can produce a situation where two (or more) list items are given the .showHeadline class, so there's overlap on the list. I can see these happening (especially #2) because the tickForward() function can run concurrently with itself, producing different sets of $active and $next. So I think my question is: What would be the best way to prevent concurrent execution of the tickForward() method? Some things I have tried or considered: Setting a Flag: When tickForward() runs, it sets an isRunning flag to true, and sets it back to false right before it ends. The logic for the event handler is set to only call tickForward() if isRunning is false. I tried a simple implementation of this, and isRunning never appeared to be changed. The jQuery queue(): I think it would be useful to queue up the tickForward() commands, so if you clicked it five times quickly, it would still run as commanded but wouldn't run concurrently. However, in my cursory reading on the subject, it appears that a queue has to be attached to the object its queue applies to, and since my tickForward() method affects multiple lis, I don't know where I'd attach it.

    Read the article

  • Connection Refused running multiple environments on Selenium Grid 1.04 via Ubuntu 9.04

    - by ReadyWater
    Hello, I'm writing a selenium grid test suite which is going to be run on a series of different machines. I wrote most of it on my macbook but have recently transfered it over to my work machine, which is running ubuntu 9.04. That's actually my first experience with a linux machine, so I may be missing something very simple (I have disabled the firewall though). I haven't been able to get the multienvironment thing working at all, and I've been trying and manual reviewing for a while. Any recommendations and help would be greatly, greatly appreciated! The error I'm getting when I run the test is: [java] FAILED CONFIGURATION: @BeforeMethod startFirstEnvironment("localhost", 4444, "*safari", "http://remoteURL:8080/tutor") [java] java.lang.RuntimeException: Could not start Selenium session: ERROR: Connection refused I thought it might be the mac refusing the connection, but using wireshark I determined that no connection attempt was made on the mac . Here's the code for setting up the session, which is where it seems to be dying @BeforeMethod(groups = {"default", "example"}, alwaysRun = true) @Parameters({"seleniumHost", "seleniumPort", "firstEnvironment", "webSite"}) protected void startFirstEnvironment(String seleniumHost, int seleniumPort, String firstEnvironment, String webSite) throws Exception { try{ startSeleniumSession(seleniumHost, seleniumPort, firstEnvironment, webSite); session().setTimeout(TIMEOUT); } finally { closeSeleniumSession(); } } @BeforeMethod(groups = {"default", "example"}, alwaysRun = true) @Parameters({"seleniumHost", "seleniumPort", "secondEnvironment", "webSite"}) protected void startSecondEnvironment(String seleniumHost, int seleniumPort, String secondEnvironment, String webSite) throws Exception { try{ startSeleniumSession(seleniumHost, seleniumPort, secondEnvironment, webSite); session().setTimeout(TIMEOUT); } finally { closeSeleniumSession(); } } and the accompanying build script used to run the test <target name="runMulti" depends="compile" description="Run Selenium tests in parallel (20 threads)"> <echo>${seleniumHost}</echo> <java classpathref="runtime.classpath" classname="org.testng.TestNG" failonerror="true"> <sysproperty key="java.security.policy" file="${rootdir}/lib/testng.policy"/> <sysproperty key="webSite" value="${webSite}" /> <sysproperty key="seleniumHost" value="${seleniumHost}" /> <sysproperty key="seleniumPort" value="${seleniumPort}" /> <sysproperty key="firstEnvironment" value="${firstEnvironment}" /> <sysproperty key="secondEnvironment" value="${secondEnvironment}" /> <arg value="-d" /> <arg value="${basedir}/target/reports" /> <arg value="-suitename" /> <arg value="Selenium Grid Java Sample Test Suite" /> <arg value="-parallel"/> <arg value="methods"/> <arg value="-threadcount"/> <arg value="15"/> <arg value="testng.xml"/> </java>

    Read the article

  • JQuery timer, how do I do this

    - by Roland
    Is there anyway to implement a timer for JQuery, eg. every 10 seconds it needs to call a js function. I tried the following window.setTimeout(function() { alert('test'); }, 1000); but this only executes ones and then never again.

    Read the article

  • How to prevent flickering on click of browser back button

    - by venlak
    Hi...I am working on Asp.Net application.I wrote the below JavaScript code to prevent the user to not going to login page on click of browser back button when he logs into the application.It is working fine for me,but from the homepage when i click on browser back button,the flickering appears due to post back.How to prevent the flickering. Please provide the solution. function preventBack() { window.history.forward(); } setTimeout("preventBack()", 0); window.onunload=function() { null; }

    Read the article

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