This week javascript little hacks

Tags: javascript, hack, mootools

This week, I encountered two little problems that can take time to fix if you don't search with the proper keywords on google.

First bug occured in Firefox 3...yes in Firefox 3! I just created an absolute positionned div in javascript with a textfield inside. The problem was that the focus was on the textfield as I wanted but we could not see the blinking caret!..quite disturbing as a user experience.
The bug is well known and not new. The solution was just to use position : fixed instead of absolute. (but not for IE6..it would broke my design). As I use mootools I wrote something like this (you can make it shorter of course):


if(Browser.Engine.trident4){
myDiv.set({
'styles':{
'position':'absolute'
}
});
}else{
myDiv.set({
'styles':{
'position':'fixed'
}
});
}


And the problem was fixed!..hehe [When I found the solution I remembered then that I had the same problem last year...fail from me...]

Second problem was in IE using mootools 1.2 and the drag & drop stuff...It simply did not work as IE doesn't manage the event the same way, I found the solution in the google group for mootools : just add somewhere the following line and rock'na roll! :

document.ondragstart = function () { return false; };

--

<-My fixie quest (part three)   Ride bicycles! ->