View Full Version : dynamic tab script and external javascript files

07-12-2008, 08:43 AM
Hi, your tutorials are really helpful to me . i have a problem ( challenging with for some days ) when i used this tab script (http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/ajaxtabs_suppliment.htm ) and i include other PHP files through tabs my only problem is that JavaScript in that file will be disabled and can not be read .

more explanation :
i have JavaScript files that are included in each of my php files . when i include php files in tab script and click on the tab the javascript in that php file can no be read .

any suggestion would be appreciated .

07-12-2008, 07:55 PM
If the external pages contain JavaScript (especially run time scripts), you'll need to switch to using the IFRAME mode of fetching them for those tabs (versus Ajax mode).

07-12-2008, 09:01 PM
thanks, I guessed that solution and i switched to using Iframe ( my only problem is how to create preloading for Iframe )

I used ( onload ( sth) ) but with no appropriate result.

It would be fine if you explain how to create a preload function for Iframe .


07-12-2008, 09:56 PM
One way to preload the IFRAME contents it to load them inside invisible IFRAMEs when the page first loads. Inside the ajaxtabscontent.js, below the following line, add the lines in red to do this:

this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
if (this.tabs[i].getAttribute("rel")=="#iframe"){ //preload IFRAME contents
document.write('<iframe src="'+this.tabs[i].href+'" style="position:absolute;left:0;top:0;visibility:hidden"></iframe>')

07-12-2008, 10:40 PM
I add your codes to the js file but to make it clear :

i want this code to be appear in tab section :

ddajaxtabssettings.loadstatustext="<img src='ajaxtabs/loading.gif' /> Requesting content..."

so there would be no difference between Iframe and ajaxcontent

My question is where to add it ?

10-20-2010, 12:45 PM
Hey guys.

I'm sorry for pulling this old thread to the top but it explains exacly my problem.

I'm using the Ajax Tabs 2.2 to get content from 7 websites and want to preload each iframe. The on-demand-load is much to slow cause of the webpages self so the preload would be "feeling" much quicker.

The tabs are implemented via:
<li><a href="link_to_url" rel="#iframe">link</a></li>

The described workaround (code in red) is implemented and the iframes will be injected properly but if I click on a tab the iframe will be loaded at that moment again.

I also tried the href="'javascript: instance.loadiframepage('pageurl)'" but then the tabs are not working anymore.

The script initializing is done via the example code:

var countries=new ddajaxtabs('countrytabs', 'countrydivcontainer')
countries.setselectedClassTarget('link') //'link' or 'linkparent'

I read the howto 3 times but I'm not able to determine the root cause.

Can someone tell me what to do or is able to complete the code?

This would be very nice!
Thank you very much,
Kind Regards

10-21-2010, 06:08 PM
The described workaround (code in red) is implemented and the iframes will be injected properly but if I click on a tab the iframe will be loaded at that moment again.

I'm a little confused- are you saying the preload code works as far as no errors are generated, but that the contents of your IFRAMEs are still not preloaded?