HighDots Forums  

Re: onmouseup isn't always triggered when mouse button is released

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: onmouseup isn't always triggered when mouse button is released in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
yawnmoth
 
Posts: n/a

Default Re: onmouseup isn't always triggered when mouse button is released - 08-26-2008 , 04:50 PM






On Aug 26, 11:48*am, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de>
wrote:
Quote:
yawnmothwrote:
[...]
If I comment out "document.getElemenById("demo").onmousedown =
mousedown;", it works. *Why would that make a difference?

Your forgot a "t".
Yup - thanks to both you and Stevo for pointing that out!

Quote:
The ID is unnecessary. *Probably someone has told you that before.
Someone has. Note that I didn't actually reference it with a
getElementById call. I just copy / pasted the HTML (I don't have the
DOCTYPE memorized, for instance) and I guess there was a redundancy I
was unaware of. Kinda like having any id that you don't use - they
could all be deleted if you noticed them.

Quote:
div style="background: black; width: 50px; height: 50px" id="demo"

You should also define the foreground color, and declare everything in the
CSS rule for the `#demo' selector.
I think for a real live production website that's definitely a good
idea. The main point of CSS is to separate content from aesthetics -
to make it so you don't have to edit the HTML to alter the layout.

For a quick little thing like this, though, I'm not sure why it'd
matter? If you had a style tag you could even split the CSS rules for
#demo up into multiple groups which would make it a bit more difficult
for someone to see what you're doing, even though it might be more
concise...

Quote:
script type="text/javascript"
document.body.onmouseup = mouseup;
document.getElemenById("demo").onmousedown = mousedown;

You should not be mixing proprietary and standards-compliant features (at
least not without feature test).
For that matter, it seems like feature tests are probably worth while
for even standards-compliant code? Just because someones browser
supports JavaScript1.3 doesn't mean someone can't come along with a
browser only supporting JavaScript1.2.

Quote:
function mouseup() {
* alert("test");
}

function mousedown() {}

Function expressions are widely supported nowadays, it does not appear
necessary to use function declarations here. *Especially not when you
use the W3C DOM which AFAIK was not implemented by user agents that only
supported JavaScript versions before 1.2.
I'll have to keep that in mind... thanks!


Reply With Quote
  #2  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: onmouseup isn't always triggered when mouse button is released - 08-26-2008 , 05:10 PM






yawnmoth wrote:
Quote:
Thomas 'PointedEars' Lahn wrote:
yawnmothwrote:
[...] <div style="background: black; width: 50px; height: 50px"
id="demo"
You should also define the foreground color, and declare everything in
the CSS rule for the `#demo' selector.

I think for a real live production website that's definitely a good idea.
[...] For a quick little thing like this, though, I'm not sure why it'd
matter?
Decreasing maintenance effort.

Quote:
If you had a style tag
Given that there is no such thing, what exactly do you consider a `style tag'?

Quote:
you could even split the CSS rules for #demo up into multiple groups
which would make it a bit more difficult for someone to see what you're
doing, even though it might be more concise...
Your reasoning is flawed. IDs must be unique in a document.

Quote:
script type="text/javascript"> document.body.onmouseup = mouseup;
document.getElemenById("demo").onmousedown = mousedown;
You should not be mixing proprietary and standards-compliant features
(at least not without feature test).

For that matter, it seems like feature tests are probably worth while for
even standards-compliant code?
Yes, DOM standards may not be (fully) supported, and to every implementation
of them there has to be a proprietary beginning.

Quote:
Just because someones browser supports JavaScript1.3 doesn't mean someone
can't come along with a browser only supporting JavaScript1.2.
You misunderstood. This is not a matter of the programming language, but of
the APIs used with it.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee


Reply With Quote
  #3  
Old   
yawnmoth
 
Posts: n/a

Default Re: onmouseup isn't always triggered when mouse button is released - 08-26-2008 , 05:34 PM



On Aug 26, 4:10*pm, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de>
wrote:

Quote:
If you had a style tag

Given that there is no such thing, what exactly do you consider a `style tag'?
This?:

http://www.w3schools.com/TAGS/tag_style.asp


Reply With Quote
  #4  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: onmouseup isn't always triggered when mouse button is released - 08-26-2008 , 07:15 PM



yawnmoth wrote:
Quote:
Thomas 'PointedEars' Lahn wrote:
If you had a style tag
Given that there is no such thing, what exactly do you consider a `style tag'?

This?:

http://www.w3schools.com/TAGS/tag_style.asp
You have just said Jehova[tm]:

<http://groups.google.com/groups?as_q=w3schools.com&as_ugroup=comp.lang.java script&scoring=d&filter=0>

IOW, you have chosen a poor reference; I don't understand why it is still in
the FAQ, and I strongly recommend you find a better one. Contrary to what
it states, it attempts to describe the HTML `style' element instead, with
its `<style ...>' start tag and and `</style>' end tag, which enclose, of
course, its content.

<http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.1>

Although there is surely no shortage of evidence for that there, that your
choice has been a poor one can easily be proven in this instance: this part
of the Web site describes `xml:space' as a "standard attribute" of the "HTML
<style> tag". However, HTML is a application of SGML; an `xml:space'
attribute would require namespace support which only applications of XML can
provide. And in fact, it is an attribute of the *XHTML* (1.0) `style'
element, a completely different animal.

Rest assured that the documentation and example code that you can find there
are equally flawed.


HTH

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.