Results 1 to 6 of 6

Thread: body onload causing conflict with php includes

  1. #1
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default body onload causing conflict with php includes

    1) Top Navigational Bar II

    2) http://www.dynamicdrive.com/dynamicindex1/topnavbar.htm

    3) I have worked with this script and it works well in my header.html file. No problems. However, when I pull this file as an include in my index.php file <?php include ('./includes/header.html');?> I run into problems. Everything loads; however, it keeps reloading the entire page, over and over and over. My problem seems to be the onload statement in the body tag <body onload="init()">. Is there anywhere else I can put this function that won't cause a conflict with my php includes?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,076
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    Well, the script does need to initialize after the browser has parsed the page. There are other ways to do this, generally if an onload event that is usually fine in the body tag causes a problem, there is a conflict with another javascript. If it is just a simple onload conflict, the other script should be removed, or have its onload event combined with this one. The function name 'init()' is such a common one though, you may have more than one of those, or you may have more than one of something else, either would require a different solution. However, it is always possible that something else is going on in this case.

    Please post a link to the page on your site that contains the problematic script so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Links

    The link to my header file is: [URL="http://www.signaturerealestatepro.com/includes/header.html"]and this works fine on its own.

    However, when I call it with my index.php file as an include I experience trouble. The link to that page is:
    http://www.signaturerealestatepro.com/index.php

    The code for index.php is as follows:

    <?php

    // This is the main page for the site.

    // Set the page title and include the HTML header.

    $page_title = 'Signature Real Estate Professionals';
    include ('./includes/header.html');

    ?>

    <div id="left-side">This is the left side of your page.</div>
    <div id="right-side" align="center">
    <p align="center"><font size="2"><b>List with us and we'll<br />advertise your home in our<br/><i>Signature Real Estate Homes Guide</i><br/>
    <img src="\includes\images\homeguide.jpg" border="1" width="155" bordercolor="darkblue"><br/>
    We advertise with full color exterior<br/>
    pictures, publish a new issue each<br/>
    month, and distribute 1,000 copies of<br/>
    each issue! Increase your exposure<br/>
    - list with us - we will sell it!</b></font><br/><br/><br/></p>

    <p align="center"><script src='http://voap.weather.com/weather/oap/60115?template=LAWNH&par=1004384503&unit=0&key=85ec205e94b8078398d633d3b7360614'></script><br/><br/><br/></p>
    <P ALIGN="center"><A
    HREF="http://www.hsh.com/landgif.html"> <IMG SRC="http://www.hsh.com/content/hshtoday-sx.gif"
    ALT="Daily Mortgage Statistics" BORDER="0"
    WIDTH="160" HEIGHT="148"></A></P>
    <p align="center"><br/><br/><img src="\includes\images\fheo.gif" alt="Fair Housing & Equal Opportunity"/></p>
    </div>
    <?php

    // Include the HTML footer file.
    include ('./includes/footer.html');

    ?>

    Thanks for your assistance!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP won't cause any problems, by itself.
    PHP outputs just text (html, javascript, css, etc.), and that is what you need to worry about.
    If it seems like the PHP is causing the trouble, then it's definitely a script on the included page that conflicts. Perhaps you have two body tags? Etc.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    <script language="JavaScript" src="navcond.js"></script>
    <script language="JavaScript">
    language has been depreciated.. use this instead

    Code:
    <script type="text/javascript" src="navcond.js"></script>

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,076
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    Seems to work equally poorly to me regardless of whether it is the header file alone or the actual page.

    In IE 7 it works OK, but there are issues with the triggers (particularly 'Resources') not always activating as expected. Seems to work fine in Opera.

    This is an old script and doesn't work in FF at all (not even on the DD demo page for the script). For that reason alone, I would highly recommend using a different script.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •