Guardian-Mage Posted March 30, 2008 Share Posted March 30, 2008 I have an external javascript file linked to in my HTML, but when I call document.getElementById('id').innerHTML it returns null. I call my function using <body onload="myfunction"> and nothing different. I am using XHTML 1.1. Any ideas? Quote Link to comment Share on other sites More sharing options...
GB_001 Posted March 30, 2008 Share Posted March 30, 2008 What are you trying to do? Quote Link to comment Share on other sites More sharing options...
Guardian-Mage Posted March 30, 2008 Author Share Posted March 30, 2008 Add content to a div Quote Link to comment Share on other sites More sharing options...
GB_001 Posted April 2, 2008 Share Posted April 2, 2008 Why don't you include it into the page with php? Quote Link to comment Share on other sites More sharing options...
haku Posted April 3, 2008 Share Posted April 3, 2008 Post your code - getElementById works fine in external functions, so its likely that your problem lies somewhere else. Show us the javascript in question, as well as the tag which you are trying to access. Finally, don't use body-onload. This isn't recommended anymore. Add this to the bottom of your external js file: window.onload = function() { // in here place the code you want executed when the page loads } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.