Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need a cutting edge solution to an identified problem!

    I have a script that runs continuously, It has a setInterval to run a function called moveOrbs. Problem is I want to use an event observer... but an event observer will not trigger until javascript finishes... and this one never does...

    Solution, I believe (hope actually) there must be some background event going on in the browser that occurs regularly, I could use that event to trigger my moveOrbs function, and thus allow javascript to stop for several milliseconds, does anyone know of such a background event?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Scratching my head.

    A function run by way of setInterval( ) *DOES* finish, assuming it doesn't have some infinite loop in it (but then you'd have bigger problems than this). And the thread is released.

    Witness the fact that you can have two or more setInterval( ) based function calls running at the same time.

    So why doesn't the event observer get a chance to run in between calls???

    What kind of event observer, specifically?

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    I assume this is same problem as prior thread?

    I went to http://huduzu.trollnest.com and there is nothing on the page except the little form at the top right. This in FF 3.

    In MSIE 6, I get the little blocks floating around, but I get tons of JavaScript errors, then.

    For example, I get "Orb[i] is not an object in this code:
    Code:
    		Event.observe(
    			'Orb'+i,
    			'mouseover',
    			function(event) {
      		Orb[i].static=1;
    			alert("hello");
    		});
    Dare I assume that the code is only intended to run in a particular browser?? Neither FF3 nor MSIE6?

  • #4
    New Coder
    Join Date
    May 2009
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, I was playing with it, and no javascript does not 'finish' on setInterval or setTimeout, it simply sets a timer to interupt it. If it finishes everything else it will idle until the timer is finished, it is almost like the timer is a seperate thread, but of course we know javascript is single threaded. I have uploaded a version that will run in slow motion and you will see how much time there is to service the event if indeed javascript had stopped. I wish (and still hold out hope) that I were incorrect. The problem with firefox is that it reports a registry undefined error from the prototype script for the mouseover event. If you have prototype and look at the line number indicated you will see that this is where the syntax differences for IE and firefox are supposed to be resolved.

    Thanks for your interest by the way!
    Last edited by Sleeping_Troll; 05-29-2009 at 03:18 AM.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Do you know why it does nothing at all in FF3??

    I do *NOT* see the <DIV> (or whatever it is) where the floating squares appear in MSIE 6.

    But it looks to me like the event observer *IS* working in MSIE 6, because ineed it gets the error *IN THE OBSERVER*!

    What browser are you running??

  • #6
    New Coder
    Join Date
    May 2009
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It does not wprk in ff because prototype is not registering the observer, that is a problem I can tackle later. I am running IE8 and FF3, IE6 has a ton of problems with images and alpha transparency, I don't even try to support it anymore. Yes it is registering in IE, it just never gets a chance to handle it. Try resizing your window very small, it will cause the script to crash and then the observer will be able to service.
    I will put an alert in the handler.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Sorry...it now at least shows in FF3. I assume you went ahead and made the change you said you needed.

    But resizing FF3 window as small as I can does *NOT* cause a crash. No alerts coming from observer, etc.

    And in MSIE 6 I get an error in a completely different place than before, but *still* I get it as a result of the mouseover observer. Unless I'm mistaken, that means the observer *IS* working, no??

    I can't look at it more tonight. I don't have MSIE 8 yet, on purpose, but I could look at it with MSIE 7, if there is any point.

    I doubt I'm going to be any help, unfortunately. I can see this would take some time to try to repro certain behaviors, and I just don't have it right now.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •