html onload help

i want to do a onload for a class.

<BODY  onload="animated()">

my JavaScript file has this

function animated()
class="<? echo $XML->body?>";

I need to have it this way because as you see i will be loading php. The main index.HTML must be HTML not php.

this is why i am using JavaScript to load php code with out changing the index.HTML to php.

How can i use jquery for addClass
Who is Participating?
armasmikeConnect With a Mentor Author Commented:
it work i got it working here it is

<BODY id="body" >


$('#body').addClass('animated fadeInDown');


and yes your right about the javascript and php it must have *.php
If that javascript file is a separate file then putting php code in it won't work, you need to put the javascript in the php page itself.

To run the .html page as php add this to your .htaccess
AddType application/x-httpd-php .html

Is this running on Apache? If not then you will need to use
AddHandler application/x-httpd-php .html
Ray PaseurCommented:
To anyone who comes across this question in the future, please do not do this:

class="<? echo $XML->body?>";

Instead, use the full PHP open-tag like this:

class="<?php echo $XML->body?>";

Or use the PHP short-echo tag like this:

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to and use offer code ‘EXPERTS’ to get 10% off your first purchase.

armasmikeAuthor Commented:
Ray Paseur  can i ask why ?
Ray PaseurCommented:
Sure.  The "short open" tag is a configuration option and is not guaranteed to be present in every PHP installation.  It also produces confusion when PHP and XML are used together.  The other two notations are supported by PHP and are not subject to configuration.
armasmikeAuthor Commented:
thank you i change all my code to use the PHP short-echo tag
armasmikeAuthor Commented:
i fix it my self
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.