I had a strange issue today. document.getElementbyId returns null, but the object was present in the view source . then I figured out that the javascript was executed on page load ,before the object was rendered. Solution: I set the defer property for