Can we you get our JavaScript to run in the first place to
assign an event handler?
How can we get an initial piece of JavaScript to run without referencing a function in your XHTML page?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Any code you put in a
<script type="text/javascript">tag will be executed immediately. Put it in your<head>and it will run before anything else. Put at the end of the<body>and it will run last.Do keep in mind that the DOM may not be fully initialized in either of those cases. If you need the DOM use
window.onloador jQuery’s$(document).ready()Also ‘XHTML’ and ‘HTML’ are not the same. XHTML is a very strict subset of HTML that in my opinion does nothing to improve upon regular HTML but it does allow for some fanciness. It has no effect whatsoever on JavaScript.