Results 1 to 6 of 6

Thread: body onLoad not working with Ajax Tabs Script

  1. #1
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default body onLoad not working with Ajax Tabs Script

    1) Script Title: Ajax Tabs Content script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tent/index.htm

    3) Describe problem:

    I am trying to load some javascript from the <head> within one of the tabs (not the very first one, but one that is loaded through a seperate .html file). The page loads fine in the div area where the rest of the tabs load when clicked on; however, the body onLoad command does not seem to be working. Does anyone know if it is possible to use body onLoad in one of the Ajax tabs that is loaded a seperate html file?

    If you go here you will see the problem: http://www.dogboston.com/temp/htms/gettingadog.php

    Click on the BREEDERS tab. Notice that the large image of the dog jumping with the ball is very large. I have an image resizing script in the <head> using javascript, but the body onLoad is not working when trying to load the page va the tab. If you click http://www.dogboston.com/temp/htms/a...t/breeders.php, you will notice that the picture is not shrunk as well as the rest of the images. This is because the onLoad is working fine when loading a regular page not inside a tab.

    Help me please!

    Thanks,

    Matt
    Last edited by mjurmann; 11-19-2006 at 04:14 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That happens. You cannot run body onload for a page that is already loaded. The page that loads in your tabbed content is already loaded. Hence, your problem. I wrote a general discussion of this issue and a way around it here:

    http://www.dynamicdrive.com/forums/s...ad.php?t=13003
    - John
    ________________________

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

  3. #3
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    That happens. You cannot run body onload for a page that is already loaded. The page that loads in your tabbed content is already loaded. Hence, your problem. I wrote a general discussion of this issue and a way around it here:

    http://www.dynamicdrive.com/forums/s...ad.php?t=13003
    John (or anyone who can help)

    Here is the code that I've placed on my top page:

    <body bgcolor="#503427" onload="onloadfunct();">

    <script type="text/javascript">
    function pollC(id, load){
    if (!load&&document.getElementById(id)){
    document.getElementById(id).id='';
    return;
    }
    else if (load&&document.getElementById(id)){
    if (id=='unique_1') //optional
    onloadfunct(); //required
    return;
    }
    else if (load&&!document.getElementById(id))
    setTimeout("pollC('"+id+"', 'load')", 60);
    }
    </script>



    <ul id="maintab" class="shadetabs">
    <li class="selected"><a href="#default" rel="ajaxcontentarea">adopt/rescue</a></li>
    <li><a href="ajaxtabscontent/breeders.php" rel="ajaxcontentarea" onmousedown="pollC('unique_1')" onmouseup="pollC('unique_1', 'load')">breeders</a></li>

    </ul>

    On my content loaded page (breeders.php) I have this at the end:

    <span id="unique_1"></span>

    </body>


    It doesn't appear that the onLoad is triggering on the content page. Did I do something wrong?

  4. #4
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    WOW, figured it out. John, thank you so much, you saved my ass.

    Have a good one!

  5. #5
    Join Date
    Oct 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help me also

    In my case, JavaScript, CSS are not working. Please solve it.

    Code is attached below.

  6. #6
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Please start a new thread for a new question.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

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
  •