Solved

html onload help

Posted on 2014-02-02
7
222 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

762 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

24 Experts available now in Live!

Get 1:1 Help Now