Monday, February 13, 2006

How did I miss Type-Ahead behaviour?

I have been doing some further work on my simple Google Suggest clone recently (I've not finished doing this yet, more on this another time). A colleague of mine brought the autocomplete or (type ahead) behaviour of Google Suggest to my attention. I have to admit that I'd never really noticed this before, it is so easy to take clever AJAX behaviour for granted (one of the reasons for AJAX's success is it just feels natural). Whilst trying to figure out how it works I tripped over a JavaScript feature that I never knew existed before. If you are viewing this as a standalone entry you will be able to see an example of it working below (fixed! I think my blog front page is too JavaScript laden for it to work there). The highlighting is achieved via JavaScript. JavaScript is also used to tell you what text is highlighted and what text is not highlighted. Here is the JavaScript.

The mechanism used (createTextRange/setSelectionRange) differs between IE and Firefox. Whilst investigating this I found the following references useful:

Google Suggest Dissected..., Creating an Autosuggest Textbox with JavaScript, Part 1 & Get Selection (from quirksmode.org)

3 comments:

madin said...

Moncler have been developing their ski-inspired apparel since founded in 1952, moncler jackets for sale popular for their luxe quilted down coats originally produced for extreme cold-weather conditions. cheap moncler parka Sportswear-inspired clothing combined with street-style provides practical and versatile daily-wear pieces including Moncler t-shirts and polos perfect under a lightweight jacket.

madin said...

Cartier watches boast a large variety of design and functionality, replica cartier ukyet maintain the utmost quality and sophistication in every series. Crafted from the finest steel, replica calibre de cartier carbon diver watchesrose gold, yellow gold, and white gold, and utlizing the highest grade of diamonds worthy of the Cartier name, Cartier has dominated the industry of elegant watches. Mens and ladies watches alike are assured attention to detail internally and externally, and the namesake itself is a milestone in the world for which the standard of reputation alone is reminiscent of the product.

madin said...

Since 1848,best replica watches Omega watches built a reputation of being the ultimate in luxurious elegance and sporty sophistication. In 1931, the replica omega watches brand entered the Geneva Observatory trials, competing in several categories designed to test the rigor and mechanical reliability of the Omega timepiece. The brand won all six categories and thereby adopted the slogan, "Omega, exact time for life." In 1965, NASA selected Omega to be the official watch used in training and space exploration. A true giant in name and reliability, Omega produces elegant watches that are impervious to changes in fashion. At , we offer a variety of Omega watches for sale — at the lowest prices online. When you are ready to buy an Omega watch, browse our selection that includes the: Seamaster, Speedmaster, 1957 Trilogy, DeVille, Planet Ocean, and Constellation.