7
Dec
2006

I wanted to share this with everyone as it's a function I would not be able to develop without... every project I start this is the first function I put into my code...

function obj(el) {


     if( document.all ) {


          return document.all(el);


     } else {


          return document.getElementById(el);


     };


};

Basically what it allows me to do it is reference any object the in DOM by using the following...

obj('divid').style.backgroundColor = 'red';

It works in IE & FF and all other browsers, I've been using it for years now and can't live without it :) Have fun with it.

Comments

1
Brent Ashley Says:

Looks familiar - I think it was a part of common.js at VFM back in the dark days of DHTML!

What do you think?

   

Subscription Zone
Stay up-to-date with newsletter from BartDabek.com!

Recent Comments

  • Belle says: You're a pretty good writer from where I'm sitting, Bart. I love...
  • Max Power says: iTunez is for suckers. Well, iTunes for the PC at least. Apple...
  • Koonta says: There's been many recent tests, and people r saying the battery...
  • Pema says: I'm not sold on the iPhone. I think symbian is a great open-source...
  • thatnimrod says: okay. let's go down the list. #1 - "Steve had problems..." Right....
  • kL says: Higher pixel density means crisper graphics and more readable...
  • stephen says: Ever stop to think that the problem with iTunes for Windows isn't...
  • Categories

    Privacy Policy | All contents copyright © BartDabek.com
    -->