onload() with PHP

B

Ben

I have a question about onload() with PHP.

my <body> tag in a file call "header.php"

my files construct like this.

header.php
<body>
<table>...

content.php
include('header.php');
contents... line 1 ...
contents... line 2 ...
contents... line n ...
include('footer.php');

footer.php
</table>
</body>

Question
knowing that onload() is used in <body> tag.
is it possible to have my onload() written in content.php?
if so, how can I do it?

Thank you very much!
 
L

Lee

Ben said:
I have a question about onload() with PHP.

my <body> tag in a file call "header.php"

my files construct like this.

header.php
<body>
<table>...

content.php
include('header.php');
contents... line 1 ...
contents... line 2 ...
contents... line n ...
include('footer.php');

footer.php
</table>
</body>

Question
knowing that onload() is used in <body> tag.
is it possible to have my onload() written in content.php?
if so, how can I do it?

Thank you very much!

The onload handler that you define in your <body> tag will not
be executed until the entire body has loaded, so any functions
that it called can safely be defined in the body.

If that doesn't answer your question, you might want to ask in
a PHP newsgroup.
 
T

Tony

Ben said:
I have a question about onload() with PHP.

my <body> tag in a file call "header.php"

my files construct like this.

header.php
<body>
<table>...

content.php
include('header.php');
contents... line 1 ...
contents... line 2 ...
contents... line n ...
include('footer.php');

footer.php
</table>
</body>

Question
knowing that onload() is used in <body> tag.
is it possible to have my onload() written in content.php?
if so, how can I do it?

Thank you very much!

If you want to be able to control which function is called and/or
written, you could try something like this:

header.php:
echo "<body onload='" . $jsFunction . "'>";
// note that's equal/single-quote/double-quote after the 'onload'

content.php:
$jsFunction = "javascriptFunctionName()";
include('header.php');

And as mentioned, any further discussion would better be done in a PHP
group, where you'll get more help on structuring the PHP, which is
probably more relevant to your needs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top