Results 1 to 5 of 5

Thread: Help with OnLoad conflict and IFrame

  1. #1
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with OnLoad conflict and IFrame

    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/in...indextest.html, to open http://www.bc.edu/bc_org/ath/plex/in...eventstest.htm with http://www.bc.edu/bc_org/ath/plex/in..._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:
    Code:
    <script type="text/javascript">
    function loadIframe(){
    if (location.search.length > 0){
    url = unescape(location.search.substring(1))
    window.frames["sport"].location=url
    }
    }
    onload=loadIframe
    </script>
    In my <body> tag I have:
    HTML Code:
    <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,
    HTML Code:
    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()"
    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!!!

    Edit: Wrapped in [code][/code] tags.
    Last edited by tech_support; 11-19-2007 at 08:41 AM.

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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:
    Code:
    	window.onload = function(){
    		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 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:
    Code:
    	<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.

  3. #3
    Join Date
    Nov 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there, Thanks for replying!

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

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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..

  5. #5
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking Not much but may be help too

    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'">


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
  •