PDA

View Full Version : body onLoad not working with Ajax Tabs Script



mjurmann
11-19-2006, 04:04 AM
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/ajaxtabscontent/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

jscheuer1
11-19-2006, 09:44 AM
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/showthread.php?t=13003

mjurmann
11-19-2006, 11:17 AM
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/showthread.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?

mjurmann
11-19-2006, 11:33 AM
WOW, figured it out. John, thank you so much, you saved my ass.

Have a good one!

BNArun
10-03-2007, 12:03 PM
In my case, JavaScript, CSS are not working. Please solve it.

Code is attached below.

tech_support
10-04-2007, 01:05 AM
Please start a new thread for a new question.