Browsing articles tagged with " JavaScript"

JS detecting event support in browsers

Apr 3, 2009   //   by Michael D. Irizarry   //   Ajax, JavaScript  //  No Comments

As you may know there is no easy way of detecting which elements supports which events across browsers. Kangax from Perfection Kills has come up with a very clever way of detecting them.

JavaScript


  var isEventSupported = (function(){
    var TAGNAMES = {
      'select':'input','change':'input',
      'submit':'form','reset':'form',
      'error':'img','load':'img','abort':'img'
    }
    function isEventSupported(eventName) {
      var el = document.createElement(TAGNAMES[eventName] || 'div');
      eventName = 'on' + eventName;
      var isSupported = (eventName in el);
      if (!isSupported) {
        el.setAttribute(eventName, 'return;');
        isSupported = typeof el[eventName] == 'function';
      }
      el = null;
      return isSupported;
    }
    return isEventSupported;
  })();

Use

isEventSupported(<"Type of Event>")

For a more detailed description visit Kangax blog

Debouncing Javascript Methods

Mar 31, 2009   //   by Michael D. Irizarry   //   Ajax, JavaScript  //  1 Comment

What is debouncing anyways? Debouncing is any kind of hardware device or software that ensures that only a single signal will be acted upon for a single opening or closing of a contact. Imagine you have a form with a few elements that a user may access thru the tab key, on each element you have an onfocus event that will trigger an Ajax call to the server to acquire some data. You could just imagine how you could kill the server with all those Ajax calls! So that’s where debouncing comes into play. With debouncing your assuring that the method will be triggered in the element that the user intended to, although is not perfect it does work better than Throttling. Read more >>

TaskSpeed – JS Framework Benchmarking

Mar 31, 2009   //   by Michael D. Irizarry   //   JavaScript  //  No Comments

TaskSpeed is a benchmarking tool for JS Frameworks. It includes tests for jQuery, Mootools, Prototype and  Dojo. Dojo 1.3 has proven to be the fastest JS framework on common DOM operations.

Make Facebook new home look like Twitters using Greasemonkey

Mar 30, 2009   //   by Michael D. Irizarry   //   JavaScript  //  1 Comment

Facebook Twitter Style is a small CSS injection to hide some parts of the new Facebook home page to make it cleaner and mimic Twitter, also hides the infamous highlights column. You can also update your twitter status from Facebook using Facebook Twitter Updates script for Greasemonkey.

Post Facebook Updates to Twitter using Greasemonkey

Mar 18, 2009   //   by Michael D. Irizarry   //   JavaScript  //  No Comments

I just finished a Greasemonkey script that I call “Facebook Twitter Updates” that lets you post Tweets from Facebooks new “Share” feature in 140 characters or less. You will be able to Tweet from Facebook using Facebooks “Share” feature.