onload() with PHP

Discussion in 'Javascript' started by Ben, Jan 16, 2006.

  1. Ben

    Ben Guest

    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!
    Ben, Jan 16, 2006
    #1
    1. Advertising

  2. Ben

    Lee Guest

    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.
    Lee, Jan 16, 2006
    #2
    1. Advertising

  3. Ben

    Tony Guest

    Ben wrote:
    > 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.
    Tony, Jan 16, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fabio R.
    Replies:
    0
    Views:
    792
    Fabio R.
    Mar 25, 2005
  2. Rajive Narain
    Replies:
    0
    Views:
    1,693
    Rajive Narain
    Sep 18, 2009
  3. David Otton

    window.onload and body.onload differences

    David Otton, Nov 4, 2004, in forum: Javascript
    Replies:
    2
    Views:
    543
    Martin Honnen
    Nov 4, 2004
  4. Replies:
    5
    Views:
    257
    Thomas 'PointedEars' Lahn
    May 15, 2005
  5. marco

    onload -->* no onload

    marco, Jun 22, 2006, in forum: Javascript
    Replies:
    7
    Views:
    202
    marco
    Jun 24, 2006
Loading...

Share This Page