Prev: Standalone .js file creates IE, and call javascript functions in the page
Next: Javascript pause or sleep thread execution
From: Jorge on 12 Dec 2009 19:46 On Dec 12, 11:09 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de> wrote: > Austin Matzko wrote: > > Thomas 'PointedEars' Lahn wrote: > >> >> e = e || window.event; > > >> Reasonable people use an `if' statement here instead. > > > Would you please elaborate? I'm curious why an "if" statement would > > be better. > > It saves one needless evaluation step, and because it allows for a block > statement it allows for a finer control, including proper feature-testing.. !e && (e= window.event); -- Jorge.
From: Stefan Weiss on 12 Dec 2009 20:22 On 12/12/09 14:05, JR wrote: > On Dec 12, 3:25 am, Stefan Weiss <krewech...(a)gmail.com> wrote: >> I use Ctrl a *lot*. I use it to operate my browser, to scroll the page, >> to copy and paste text, etc. If I saw a site where ctrl triggered a >> JavaScript alert, I would automatically mentally file it as evil / scum >> / target for abuse. At the very least, I'd add it to my list of blocked >> sites. If I'm bored I might have a look around and see what else looked >> broken. It's not very clever to annoy your guests. > > Why people always tend to generalize particular cases in c.l.js? When I hear hoofbeats, I think horses, not zebras. If the OP is working in a very unusual environment, he ought to mention that, or people will assume the general case. -- stefan
From: Asen Bozhilov on 12 Dec 2009 20:46 Thomas 'PointedEars' Lahn wrote: > You better don't quote the Specification unless you are sure what you are > talking about. What is irrelevant here? I quote specification for the problem, which are you talking about. > "Bug" was short for "suboptimal example". Quite obviously, there is no > assignment necessary when `e' type-converts to true (indeed, since `e' > refers to a host object, it is error-prone to use it in a type-converting > test). You wrote "it is error-prone", but you use exactly in the same manner. | for (var tRows = tBody.rows, i = tRows && tRows.length; i--;) Here again `tRows` refer host object and again we have type conversion. Please, don't suggest something which you don't observe. Regards.
From: Thomas 'PointedEars' Lahn on 12 Dec 2009 22:33 Asen Bozhilov wrote: > Thomas 'PointedEars' Lahn wrote: >> You better don't quote the Specification unless you are sure what you are >> talking about. > > What is irrelevant here? I quote specification for the problem, which > are you talking about. There was no need to quote the Specification to me as a *disproof* as I suggested what I did because I already knew what happened. And as it was confirmed eventually by yourself, you did not really know what you were talking about at the time. >> "Bug" was short for "suboptimal example". Quite obviously, there is no >> assignment necessary when `e' type-converts to true (indeed, since `e' >> refers to a host object, it is error-prone to use it in a type-converting >> test). > > You wrote "it is error-prone", but you use exactly in the same manner. And if you had cared to notice, I wrote the code below *before* I wrote that (the `indeed' should have been an indication). But even that hardly matters, because: > | for (var tRows = tBody.rows, i = tRows && tRows.length; i--;) > > Here again `tRows` refer host object and again we have type > conversion. Please, don't suggest something which you don't observe. This is a quick hack, untested code, evident to all who can read in context. > Regards. Somehow I doubt your sincerity. Score adjusted PointedEars -- realism: HTML 4.01 Strict evangelism: XHTML 1.0 Strict madness: XHTML 1.1 as application/xhtml+xml -- Bjoern Hoehrmann
From: Dmitry A. Soshnikov on 13 Dec 2009 09:55
On Dec 12, 6:05 am, Thomas 'PointedEars' Lahn <PointedE...(a)web.de> wrote: > Krist wrote: > > On 12 Des, 03:21, JR <groups_j...(a)yahoo.com.br> wrote: [...] > >> function keyCheck(e) { > > Reasonable people use a function expression here instead. > Pathos. > >> e = e || window.event; > > Reasonable people use an `if' statement here instead. > Troll pathos ;) Here's the main goal in how it "sounds": "let it be the same or "default" value". The most useful form would be already mentioned `e ||= window.event;`, or could be used also mentioned `!e && (e = window.event);`. All the cases are good. So, your answer just troll pathos. Any problem? ;) > >> if (e.ctrlKey) { > > Responsible developers feature-test host object's properties before they are > accessing them in a type-converting test. Then again, responsible > developers would not try this whole nonsense in the first place. > Pathos. > >> alert("CTRL key is not allowed"); > > window.alert(...); > Pathos. Plain `alert` in this concrete host environment can be better solution ;) > > > God bless you > > Said the blind led by the blind. > Troll pathos. Any questions? ;) /ds |