![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||||
| |||||
|
|
yawnmothwrote: [...] If I comment out "document.getElemenById("demo").onmousedown = mousedown;", it works. *Why would that make a difference? Your forgot a "t". |
|
The ID is unnecessary. *Probably someone has told you that before. Someone has. Note that I didn't actually reference it with a |
|
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. |
|
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). |
|
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. |
#2
| |||||
| |||||
|
|
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? |
|
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... |
|
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. |
#3
| |||
| |||
|
|
If you had a style tag Given that there is no such thing, what exactly do you consider a `style tag'? |
#4
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |