Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
You need to set your events, and set the variables btnThumbWebsite, and btnThumbGraphic inside of a function initiated by the onload event. The reason that you are getting this error is that when you attempt to use getElementById, the elements are not available yet. By waiting for them to load, you will avoid this problem.
The other solution is to place the scripts down at the bottom, right before your closing </body> tag. This will insure that all of the HTML is loaded before the script is run. The upside of this method is that the DOM is available, but you don't need to wait for images to load, unlike the onload event. Be aware, however, that scripts run in this fashion do not wait for images to be ready before they run, which will be important if you ever need to do something to images.
Last edited by wayfarer07; 07-23-2008 at 12:20 PM..
|