Posted By

sarfraznawaz2005 on 02/11/09


Tagged

javascript element getElementById


Versions (?)

Truely getElementById


 / Published in: JavaScript
 

cross-browser document.getElementById, should be on top of code.

  1. // cross-browser document.getElementById, should be on top of code.
  2. if(!document.getElementById)
  3. {
  4. if(document.all)
  5. document.getElementById=function()
  6. {
  7. if(typeof document.all[arguments[0]]!="undefined")
  8. return document.all[arguments[0]]
  9. else
  10. return null
  11. }
  12. else if(document.layers)
  13. document.getElementById=function()
  14. {
  15. if(typeof document[arguments[0]]!="undefined")
  16. return document[arguments[0]]
  17. else
  18. return null
  19. }
  20. }

Report this snippet  

You need to login to post a comment.