View Full Version : Help with OnLoad conflict and IFrame

11-19-2007, 02:14 AM
I want to apologize in advanced as I am not a coder.

I want the basketball photo link on this page, http://www.bc.edu/bc_org/ath/plex/intramurals/indextest.html, to open http://www.bc.edu/bc_org/ath/plex/intramurals/falleventstest.htm with http://www.bc.edu/bc_org/ath/plex/intramurals/fe_football.html in the iframe. It is not working right now and the conflict seems to be linked to the onload function. In my <head> tag I have:

<script type="text/javascript">
function loadIframe(){
if (location.search.length > 0){
url = unescape(location.search.substring(1))

In my <body> tag I have:

<body background="../images/nav/bg.gif" link="8a0909" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../images/nav/aboutuso.gif','../images/nav/aboutus.gif','../images/nav/aquaticso.gif','../images/nav/fitnesso.gif','../images/nav/groupfitnesso.gif','../images/nav/hourso.gif','../images/nav/instructionalo.gif','../images/nav/intramuralso.gif','../images/nav/membershipo.gif','../images/nav/clubsportso.gif');runSlideShow()">

When I remove the onLoad function in the <body> tag,


the original link that is supposed to open the page with the specific IFrame source works. How can I script this so that I can get it all to work?

I'd greatly appreciate ANY help someone could provide. Thanks in advance!!!

Wrapped in

11-19-2007, 03:34 AM
You can do this in a number of ways:

1. Instead of calling the onload methods as a part of the body tag you can keep them like the following:

window.onload = function(){

In this method as I mentioned earlier the body tag will not have a onload attribute in it. Instead you can place the above code snippet within your <script></script>.

2. You can use the existing method itself but with a bit change like the following:

<body background="../images/nav/bg.gif" link="8a0909" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../images/nav/aboutuso.gif','../images/nav/aboutus.gif','../images/nav/aquaticso.gif','../images/nav/fitnesso.gif','../images/nav/groupfitnesso.gif','../images/nav/hourso.gif','../images/nav/instructionalo.gif','../images/nav/intramuralso.gif','../images/nav/membershipo.gif','../images/nav/clubsportso.gif');runSlideShow();loadIframe();">

In this method remove the onload = loadIframe line from your script. In this manner the loadIframe method will be invoked along with other methods.

I personally prefer the first approach as it seems to be less confusing and neat.

11-19-2007, 07:16 AM
Hi there, Thanks for replying!

I tried the 1st method but it didn't work. The second did though. THANKS SO MUCH! :)

11-19-2007, 07:44 AM
I tried the 1st method but it didn't work.

If you can share your page source then I would like to have a look at it. I don't see any problem that creates problem in the first approach..

01-28-2011, 12:32 PM
try to put window.onload = yourcode; together with body unload.

i have the tool tip javascript on <head></head> which contain
window.onload = initTip;
but conflick with my
<body onload = "parent.myframe.location='mypage.html'">

my solution :
delete that window.onload = initTip; from <head></head>, then put them into <body>.

<body onload = "initTip(); parent.myframe.location='mypage.html'">