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.
Joseph Smarr gave this great talk [~50mins] at Yahoo, which contradicted many myths that I had about 'what is right' in JavaScript. (i.e. using InnerHTML is way faster than manipulating DOM)
He's cool.
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.
After some struggling with how the Daylight Saving Time change affected my code, I realized that one shouldn't mess with the time zone offsets on his own (i.e. Add or Subtract hours manually from the UTC time), because underlying libs already implement it - and probably better (yes, including DST changes, works flawlessly!). Here are the new simple rules I set to myself:
Bottom line: stick to UTC as much as you can, it's good for you.
Trivia line: Morocco is GMT+0 and has no Daylight Saving Time (so it's identical to UTC). Good for them, eh?
I've been asked to run few ajax requests in parallel.
Apparently the "A" in ajax stands for "Asynchronous", so each HTTP request made is non-blocking and unlimited HTTP requests should be made in parallel.
However, the browser limits the number of connections to a specific HTTP server. This is not a bad browser design: it's according to HTTP 1.1.
This can be tweaked (and thus breaking HTTP 1.1 compatibility):
FF: about:config -> network.http.max-persistent-connections-per-server
MSIE: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\MaxConnectionsPerServer (create it even if it doesn't exist, DWORD value)