THIS WEEK JAVASCRIPT LITTLE HACKS


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; };


Posted on : by This week javascript little hacks

Tags : javascript hack mootools

Not on G+ ?
Add a Comment - Ask a Question

 
Share



Shots from Instagram



Posts from Google +



Youtube Channel





More Articles About  Weblab



  • Google Developer Day 09 - Yokohama

    Posted on : 2009-06-11

    For the second year in a row I could enjoy this event with my co-workers from Samurai Factory. First I enjoy it because it takes place only 12mn from home by bicycle ^_^ and then of course because o...

    Read more 3


  • Fixed Gear Videos

    Posted on : 2009-02-11

    I played a little bit with the YouTube API today, using the classes provided by Zend Framework. The result is a Fixed Gear Videos Gallery. It is quite basic for now, it just retrieves the lates...

    Read more


  • Photography from Japan

    Posted on : 2008-12-29

    Just added more albums in the gallery section. Photos are hosted on zooomr, I will explain this week in a post how to get them on your homepage using the API, it's pretty much the same as for Flickr.....

    Read more


  • Blog New Features

    Posted on : 2008-11-04

    Yesterday I changed a little bit the top page of the blog. I added a new category of post called "Short News" (from Japan). Each post will be mainly composed of few pictures and just a short commen...

    Read more