View Full Version : Ajax Tabs, iframes, javascripts....

supa dupa
08-07-2008, 04:41 PM
1) Script Title: Ajax Tabs

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...axtabscontent/

3) Describe problem:

Question.... I understand that you can't use Javascript within the ajax version of this script, so I did use iframes...

A. Seems like I read somewhere that you should avoid iframes? Is this still the case and if so why?

B. The iframe does work greatly except for one issue. The iframe I need to use is rather small (about 200 pixels high.) Problem is that the javascript I am using is for a pop-up video window that is taller than this so that the video pops up within the iframe but the top and bottom visibly get cut off. (The height of the iframe does need to be exact for design reasons.) So, it appears that my only solution would be to use the ajax version, but it appears that that is a no-can-do.

It appears that there isn't any solution for this, but just wanted to double check to see if anyone had any ideas.

Thanks for your help and for the great script!

08-08-2008, 06:14 AM
a) I haven't personally run across any threads saying you should avoid IFRAMEs, at least when it comes to this script.

b) The height of the IFRAME defaults to the height of your content container DIV. If you increase the DIV's height, it should cause the IFRAME to heighten as well. Or inside the .js file, you can explicitly set a height for the IFRAME with the code in red:

this.defaultIframe='<iframe src="about:blank" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" class="tabcontentiframe" style="width:100%; height:auto; min-height: 100px; height: 300px"></iframe>'

supa dupa
08-13-2008, 09:53 PM
Hi ddadmin. Just saw your reply. I actually was able to solve this issue. I wasn't able to use the iframe because the iframe by design had to be short vertically and the pop-up videos were taller so it didn't look right. Thankfully all of the pop-ups used the same javascript that was already on the top page, so my issues were fixed when I just adjusted some code.

However...... I do have one other question. I am using drop down menus on my site, however, when this is run:

<script language="JavaScript1.2" type="text/javascript">mmLoadMenus();</script>

It really adds to the loading time of the page as I have a lot of menus. So, I was going to use the Ajax Tabs as basically an On and Off button to make these drop down menus appear and dissapear. So, I don't need to dynamically load any javascript in the head, but I do need to load the mmLoadMenus line above right after the Body tag.

I have tried:

putting mmLoadMenus() in the onajaxpageload area

I have tried the POLL method mentioned in another thread.

Any other possible solutions in this case?

Thanks very much!


08-14-2008, 05:56 AM
Hmm using the Ajax Tabs content script to render and display a script dynamically only works if you're using the IFRAME mode of the later, which probably isn't what you want. The problem is that mmLoadMenus(); most likely contains run time JavaScript (ie: using document.write() or .innerHTML inside the code) that will fail if you try to invoke them dynamically using Ajax, hence their "run time" nature.

For the sake of ease of mantainance down the line, I'd just try and compress the menu script as much as possible using the available JavaScript compressors out there.