PDA

View Full Version : dynamic tab script and external javascript files


aneeshtan
07-12-2008, 09: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 .

ddadmin
07-12-2008, 08: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).

aneeshtan
07-12-2008, 10: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 .

tanks

ddadmin
07-12-2008, 10: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>')
}

aneeshtan
07-12-2008, 11: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 ?