By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,256 Members | 1,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,256 IT Pros & Developers. It's quick & easy.

Problem with body onLoad

100+
P: 219
I'm trying to have a function called when the page loads. I have this in my code

Expand|Select|Wrap|Line Numbers
  1. <body onLoad="load()">
  2.  
then my javascript:
I commented out all my lines and am using only an alert to make sure it's working, but I'm seeing an error displaying "Object Expected". My function isn't expecting an object, what gives?

Expand|Select|Wrap|Line Numbers
  1. function load(){
  2.     alert("hi");
  3. //    var el = document.getElementByTagName("input");
  4. //    for(i=0;i<el.length;i++){
  5. //        alert(el[i]);
  6.         //el[i].addEventListener("click", clearField,false);
  7.     }
  8.  
Oct 17 '07 #1
Share this Question
Share on Google+
2 Replies


100+
P: 428
you didn't comment the function brackets correctly, so it was never defined.
don't call a function 'load'- several browsers define a global window.load method
Oct 17 '07 #2

100+
P: 219
you didn't comment the function brackets correctly, so it was never defined.
don't call a function 'load'- several browsers define a global window.load method
Ok cool thanks. I'll do that now.
Oct 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.