?
Solved

html onload help

Posted on 2014-02-02
7
Medium Priority
?
237 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 111

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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

Author Comment

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

764 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