PDA

View Full Version : body onload causing conflict with php includes



bcursio
09-16-2007, 11:06 PM
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?

jscheuer1
09-17-2007, 04:07 PM
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.

bcursio
09-17-2007, 05:10 PM
The link to my header file is: [URL="http://www.signaturerealestatepro.com/includes/header.html"] (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!

djr33
09-17-2007, 06:45 PM
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.

boogyman
09-17-2007, 06:50 PM
<script language="JavaScript" src="navcond.js"></script>
<script language="JavaScript">

language has been depreciated.. use this instead



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

jscheuer1
09-17-2007, 09:38 PM
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.