Solved

html onload help

Posted on 2014-02-02
7
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 110

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

695 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