How to run a function when the page is loaded?

window.onload = codeAddress; should work – here’s a demo, and the full code: <!DOCTYPE html> <html> <head> <title>Test</title> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> <script type=”text/javascript”> function codeAddress() { alert(‘ok’); } window.onload = codeAddress; </script> </head> <body> </body> </html> <!DOCTYPE html> <html> <head> <title>Test</title> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> <script type=”text/javascript”> function codeAddress() { alert(‘ok’); } … Read more

Checkbox hidden on body load [closed]

I think you’re looking for document.onready which is available using jQuery, but to keep it with javascript, as in your question, I suggest you move your javascript call to the end of the document. The onload will execute before the checkbox is rendered, that’s why you’re getting the error. Try the following approach: <html xmlns=”http://www.w3.org/1999/xhtml”> … Read more