Email conversation
From | Per-Åke Franklind |
To | Me |
Subject | Slider control creator |
Date | 1 September 2005 17:20 |
Hi and thx for great scripts!!!
I'm not sure if it is an error or not I have added this code to avoid JS
warning like this:
Varning: reference to undefined property document.onmousemove
Org;
if( document.onmousemove == slideIsMove ) { return false; }
//protect against multi-button click
My suggest:
if(document.onmousemove != null && document.onmousemove == slideIsMove ) {
return false; } //protect against multi-button click
[Ed. DO NOT USE THIS BROKEN CODE!]
Regards
Per-Åke Franklind
From | Me |
To | Per-Åke Franklind |
Subject | Re: Slider control creator |
Date | 1 September 2005 18:12 |
Per-Åke,
> if(document.onmousemove != null && document.onmousemove == slideIsMove ) {
> return false; } //protect against multi-button click
This check for "!= null" is not needed. Allow me to explain:
* Before it has been defined, it should be "undefined" not null. IE makes it
null (the others do not), but that is a bug in IE.
* If it is undefined, it will not be null either, so your test will fail.
* checking != null is almost _never_ needed. It is much easier and more
reliable [because of the null vs undefined inconsistencies] to use
if(!document.onmousemove)
* if it is null or undefined, then it also will not be slideIsMove,
therefore my test will _always_ be correct, without the need for your extra
test (which references the exact same variable as mine so if mine had any
problems, so should yours)
However, I was wondering where you got that error message, since I do not
see it in any of the browsers I have here. Referencing an undefinced
property is perfectly ok in JavaScript (it is illegal in VBScript, but this
is not VBScript) - some debuggers might warn you, but that is not a problem.
If any browser is throwing an error, the browser is wrong and I need to do
something to avoid it. Or are you using some JavaScript debugger that is
incorrectly reporting errors?
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Per-Åke Franklind |
To | Me |
Subject | Re: Slider control creator |
Date | 1 September 2005 18:21 |
Hi,
I'm using Fx 1.0.6 and the "warning" is from Web developer 0.9.3 (plugin)
with "strict JavaScript warnings" like missing declaration and warnings for
redeclarations (it is some of these to, but them I have fixed)
Regards
Per-Åke
From | Me |
To | Per-Åke Franklind |
Subject | Re: Slider control creator |
Date | 1 September 2005 18:45 |
Per-Åke,
> I´m using Fx 1.0.6 and the "warning" is from Web developer 0.9.3 (plugin)
> with "strict JavaScript warnings" like missing declaration and warnings for
> redeclarations (it is some of these to, but them I have fixed)
bah, that's ridiculous :D that is _waaay_ too strict. It would be impossible
to write javascripts that did proper object detection and still did not get
any warnings. Cross browser scripting relies on object detection, that is
the right way to do it. That extension sounds like more trouble than it is
worth since it is actually encouraging you to program incorrectly (testing
against null which is complete nonsense). Get rid of it.
Those warnings are there only for you while you are developing so you can
see if you are going to make mistakes. Once your script is working properly
(which the slider script is), you can ignore them. I already know that what
I am doing is ok, you do not need to include your "fix" - especially since
your fix will not work the way you want anyway.
Tarquin
Ed. Note: I found it hard to put into words my disgust at an extension that would encourage such damaging practices.
Once I had a bit of time to think about it, I wrote a proper
article explaining why it is such a problem. Take my advice;
do not use this extension, or the preference that it relates to. If you see anyone else using it, point them at my article
and get them to stop using the extension, because it needlessly damages compatibility on the Web.