Solved

html onload help

Posted on 2014-02-02
7
223 Views
Last Modified: 2014-02-07
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
0
Comment
Question by:armasmike
  • 4
  • 2
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39827834
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
0
 

Accepted Solution

by:
armasmike earned 0 total points
ID: 39827837
it work i got it working here it is


<BODY id="body" >



$(document).ready(function(){

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

});

and yes your right about the javascript and php it must have *.php
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39827899
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:

class="<?=$XML->body?>";
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:armasmike
ID: 39827912
Ray Paseur  can i ask why ?
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39828008
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.
0
 

Author Comment

by:armasmike
ID: 39828164
thank you i change all my code to use the PHP short-echo tag
0
 

Author Closing Comment

by:armasmike
ID: 39841377
i fix it my self
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now