PDA

View Full Version : Ajax Tabs Content Script (v 2.2) IFRAME AutoResize HELP!!



jrheeder
06-30-2008, 01:16 PM
1) Script Title: Ajax Tabs Content Script (v 2.2)

2) Script URL (on DD): Ajax Tabs Content Script (v 2.2) (http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm)

3) Describe problem: I am currently using the Iframe feature, but I was just wondering or is there any possibility on adding a autoresize (height resize) feature in to expand the iframe when the content is too much, I want to avoid using the scroll function. PLEASE SOMEONE HELP!!!!

ddadmin
06-30-2008, 10:02 PM
You may want to do a search on the forums, as this has been asked a few times, and there are a couple of user suggestions I believe on how to do this. Officially there's no modification released to do this yet. There is a mod that lets you manually specify a different IFRAME height depending on the tab: http://www.dynamicdrive.com/forums/showthread.php?p=132566

jrheeder
07-01-2008, 09:38 AM
You may want to do a search on the forums, as this has been asked a few times, and there are a couple of user suggestions I believe on how to do this. Officially there's no modification released to do this yet. There is a mod that lets you manually specify a different IFRAME height depending on the tab: http://www.dynamicdrive.com/forums/showthread.php?p=132566

DD,

Thank you for the response. :confused: Now unfortunately my strengths are not in javascript so for me to edit the original .js file from the Ajax tab file to include the code (attached below) from Iframe SSI script II (http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm) is past my knowledge and I fear that it will go wrong. . . So if you or anyone can show me how and where is add this code so it can work properly with the original Ajax tab setup, I REALLY would appreciate it.

The code:

<script type="text/javascript">

/***********************************************
* IFrame SSI script II- Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

</script>

jrheeder
07-01-2008, 09:21 PM
No-one Has any idea how to combine these two features :eek: :(

ddadmin
07-02-2008, 01:31 AM
There's a reason why there isn't an official modification that integrates the two scripts right now- it's a rather complicated (not to mention less than elegant) task. :) This is a feature that if added, will only come when the script is officially updated the next time, and probably written from scratch instead of trying to piece two scripts together.

In the meantime, if you need help implementing the more restricted feature in the thread I mentioned (http://www.dynamicdrive.com/forums/showthread.php?p=132566), you can post them here.