PDA

View Full Version : Expandable iframes (Urgent)



chrisgocrazyH
29-06-2008, 11:32 PM
Hey im using expandable iframes on my site but the probleam is they dont expand on IE only FF

My code is:


<script>

var iframeids=["contents" , "say" , "player2"]
var iframehide="yes"
var getFFVersion=navigator.userAgent.substring(navigat or.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 47 : 0
/*
Internet explorer seems to think it can make it's own rules about the internet.
*/
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+FFextr aHeight;
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>


MY Link is:

<a target="contents" href="community.php" style="text-decoration: none">
<font color="#FFFFFF">Community</font></a>
My iframe is:

<iframe src="http://simplyhabbo.com/hx/simplyhabbohome.php" width="100%" id="contents" marginwidth="1" marginheight="1" name="contents" scrolling="no" border="0" frameborder="0" allowtransparency="yes"></iframe>

Protege
30-06-2008, 02:55 AM
Theres something called a search button, "http://www.habboxforum.com/showthread.php?t=485016&highlight=expandable+iframes", Theres a result to help you.

You've officially just wasted a valuable 1kb of data space on Habbox's database, Please... please don't waste anymore - Think of the kids.

iUnknown
30-06-2008, 06:07 PM
This problem tends to be a problem with the page you want to show in the iframe rather than the code. So check there are no stupid errors that IE might be picking up.

Also, you can use these codes for your iframe:


<script type="text/javascript">
//<![CDATA[
window.onload = function() {
var f = document.getElementById("main");
function resize() {
var h = "";
var w = "";
if (f.contentDocument) {
h = f.contentDocument.documentElement.offsetHeight + 20 + "px";
// can't find anything for Opera and Firefox that works for the width. OffetWidth doesn't work right either.(f.contentDocument.documentElement,"").getPropertyValue("width");
} else if (f.contentWindow) {
h = f.contentWindow.document.body.scrollHeight + 5 + "px";
} else {
return;
}
f.setAttribute("height",h);
f.parentNode.setAttribute("height",h);
}
if (window.addEventListener) {
f.onload = resize;
} else if (f.attachEvent) {
f.attachEvent("onload", resize);
} else {
return;
}
resize();
}
//]]>
</script>

That's to go in your <head> tags on the main page.

And this is your iframe:


<iframe name="main" id="main" src="home.html" width="556" frameborder="0" allowtransparency="yes" scrolling="no" ></iframe>

Independent
30-06-2008, 09:55 PM
Oh, what a shame.

I hate iframes anyway.

On topic post: iUnknown I've seen that code on HFFM.

iUnknown
03-07-2008, 11:04 AM
Oh, what a shame.

I hate iframes anyway.

On topic post: iUnknown I've seen that code on HFFM.

Yeah it's on loads of websites, it's a free code.

Want to hide these adverts? Register an account for free!