I've previously written about HTML 5 canvas tag, we all heard about the video/audio tags, but this one sounds really awesome: HTML 5 storage. Yet another good article by PPK.
Wah, 3 posts in 12 hours.
I've previously written about HTML 5 canvas tag, we all heard about the video/audio tags, but this one sounds really awesome: HTML 5 storage. Yet another good article by PPK.
Wah, 3 posts in 12 hours.
It's been a long time since I wrote something about web-dev, that's because I code less web-stuff recently 🙂
so far, I thought that "id" should be used for unique IDs, and "name" can be used for non-unique names, i.e. multiple HTML tags with the same name. I've been using document.getElementsByName(str) to get an array of elements with the same name.
Today I've figured out that it's only partially legal: the name attribute can be used only for specific elements (such as INPUT), but cannot be used on many elements (such as DIV). For some reason, Firefox accepts the name tag for any HTML element, while IE follows HTML 4.01 and doesn't accept name tags for "illegal" HTML tags.
The next piece of JS/HTML code, gives different results on both browsers:
<div name="foo">bla</div>
<script type="text/javascript">
alert(document.getElementsByName("foo").length)
</script>
Results:
Here is a nice explanation with a full list of "name"-allowed HTML tags.
HTML 5 introduces the Canvas element, which enabled javascript "free drawing". Check this cool canvas example.
Apparently it's already supported by all modern browser except IE - which needs the Explorer Canvas plugin.
In the following code, I wanted the parent div to expand to the size of the child. But it doesn't work this way:
<div id="parent">
<div id="child" style="width: 500px">Child Text</div>
</div>
Instead, the parent takes 100% of the screen width and does not shrink to the width of the child. Quite a long googling revealed some interesting facts:
Today I wanted to catch a 'mouse-out' event in a div. Every time the mouse leaves the div, I want to call a function So.. there's the onmouseout event which, at first sight, does exactly what I needed.
<div id="parent" style="height: 500px; width: 500px;" onmouseout="alert('out!');">
<table id="child"><tr><td>child text</td></tr>
</div>
HOWEVER - if the div contains child elements (it usually does.. like above example), when mouse moves from the "bare naked" div directly to its child element, an 'onmouseout' event is called from the div, while the mouse is still inside the borders of the div. And the worst news is that it's not a bug! 🙂
So straight to the sad solution: onmouseleave event does exactly what I needed, but isn't standard and is IE-only (same goes for onmouseenter). As Rick summed it in the post which solved my issue today: "Bummer."
So bummer, but the good thing is that among the reads, I've found this must-read article which talks about the order browsers handle the events, and how to deal with it.
I didn't fully understand it from w3schools description, so here's a simpler (IMO) explanation after digging the issue a little bit:
I like it when people define modern standards, and are not afraid of making changes. And it's still backward compatible.