document.getElementById not returning elements on initial page load

View: New views
1 Messages — Rating Filter:   Alert me  

document.getElementById not returning elements on initial page load

by simon_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey,

I was wondering if someone could help me.  I've written a small script to fill in a form which I have to do a lot for me work.

I'm getting something strange happening where the script does not work when I first load the page.  If I refresh the page then the script works and the form is filled as expected.

The page doesn't change upon requests.  What is more, I can inspect the source and the DOM and the element which is reported as being null (document.getElementById is returning it null) is there.

I can also inspect the page via a Javascript shell in that page's context.  Running document.getElementById in the shell returns the element correctly.

Has anyone ideas for what this may be?