| | Author | Message |
|---|
southernyankee
| #1 posted July 15, 2009 at 8:45pm (EDT) edited July 15, 2009 at 8:45pm (EDT) |
Theres this problem I've "solved" when doing something in Java Script. Basically, there was this text field which had an onBlur attribute that would submit the form. There was also a cancel button, that had an onClick attribute that would cancel any changes you've made. Well, the problem was the onBlur event when you lose focus on the form happens before the onClick event. So you pretty much can't click the cancel button after having left this particular field.
Anyway, my "solution" was to just use the onFocus attribute instead of the onClick. Apparently that one gets fired a little before the onBlur, which takes care of the problem. Then I just add a few variables to prevent racing conditions and thats it. What I am worried about is how the events would fire if the user was using a different browser, or even using a different OS. Does anyone know how exactly are the events implemented? | bill
| | #2 posted July 16, 2009 at 7:25am (EDT) |
I don't really know. Sorry. | FauxLo
| | #3 posted July 17, 2009 at 12:54am (EDT) |
Get a new computer?  | bill
| | #4 posted July 17, 2009 at 6:40am (EDT) |
reboot! | they
| | #5 posted July 17, 2009 at 9:12am (EDT) |
I know nothing.
But are you using IE8? | FauxLo
| | #6 posted July 17, 2009 at 12:27pm (EDT) |
they = knower | southernyankee
| | #7 posted July 18, 2009 at 12:32pm (EDT) |
FauxLo wrote:
> Get a new computer?
Unfortunately that won't work. This is essentially a web page sitting on a server that thousands of users will access from their own computers. It will work for most, but it might not work for everybody. Are you gonna tell thousands of people what version of internet explorer and what OS they should have? | southernyankee
| | #8 posted July 18, 2009 at 12:33pm (EDT) |
they wrote:
> I know nothing.
>
> But are you using IE8?
No, I tested it using IE6. Everything worked fine without any bugs. I am worried about potential bugs that might pop up in the future. So far everyone is happy, but its best to be proactive about these things. | FauxLo
| | #9 posted July 20, 2009 at 1:17pm (EDT) |
southernyankee wrote:
> Are you gonna tell thousands of people what version of internet explorer
> and what OS they should have?
Of course not, but I have no problem telling people what I think will make them happier in the long run.  | cloudhugger
| | #10 posted July 21, 2009 at 10:15am (EDT) |
 | Kristal_Rose
| | #11 posted August 13, 2009 at 5:07pm (EDT) |
Modularize. Write your own event handler.
For every method, like widget.onblur() call something like widget.onblur() = myhandler(this.ID).
That way you have one location in which to manage firing sequences of different browsers, and divorce html sphaghetti code presentation from code behavior.
myHandler would then contain a sort of state machine, which works just as well with the bubble-up event hierarchy of IE as the bubble-down hierarchy of Mozilla (or the other way around.) There is no standard for event firing sequences, and they are in fact even opposite on the two main platforms (at least from the nested perspective). fun fun fun. | southernyankee
| | #12 posted August 15, 2009 at 11:54pm (EDT) |
Thanks, but you're way overthinking this. Besides, JavaScript (not to be confused with Java) is very limited. I guess I could write my own library that does just that, or better yet steal one, but that won't change the inheritant limitations of JavaScript and web page in general. Anyway, I figured out a much more mundane way of handling the event firing problem: write my own sleep function with an infinite loop that breaks after so much time passed.
I did however end up getting stuck with an entirely unrelated error though, but thats a different rant for a different day. | Kristal_Rose
| #13 posted August 16, 2009 at 4:36pm (EDT) edited August 16, 2009 at 4:40pm (EDT) |
That's a kluge. Easier to write, for sure, but eek, esp. since machine times are all so relative and evolving.
The other nice thing about creating one's own event-handler module (which is like Java, come to think of it), is that it makes migration to something like a Flash display easier - no code in the html at all.
Of course when I came up with this model I had building an on-the-fly Ajax application delivery platform in mind, not just getting some frikken web page to work cross-browser.
I don't recall specific events, just that event sequences were opposite. That said...
If you had a page looking for img-click, set up an array tracking img-click and page-clicked, any time either happens (the order depending on your browser), your module checks to see that both have fired before launching your function.
I found that robust complex cross-browser js generally requires so much hassle. For large apps though, it's not a terrible hassle because the modularity eases code modification.
~
I don't consider js all that limited (granted, I only use it in conjunction with php now). What's your complaint? The four main browser players are all now racing to create openGL/directX card rendering hooks from within js, which could significantly affect the online gaming market. Currently IE6-8 tops out at managing 2048 divs containing vertices, but even without oGL/dX one could build a slow 3D RPG game on FF. Some features like manual garbage collection sure would be nice though.
~
Lately I've been looking into procesors capable of supporting 1000's of parallel threads, as required for a touch-sensitive stereographic spherical monitor emulating vectored pond ripples to control a musical instrument (by multiplying the ripple frequency inference patterns into the audio frequencies). I can get by with a SIMD chip, recording the whole pixel world as a frame, and caching and flushing pixel-procedure commits one world frame at a time; all the parallel instructions work on their private cache of neighbor-vector data, then commit composite results (in sequence) as if at once.
You should know by now that I over-think most everything.
Good luck. Look forward to your next rant. | bill
| | #14 posted August 17, 2009 at 1:08pm (EDT) |
A side note. I've been reading about and just starting to use jQuery a little and it seems good. |
Topic Page Hits: 1 today (3 in the last 30 days) |