PDA

View Full Version : [TUT] How to make expandable iFrames



Meti
15-05-2008, 07:16 PM
Hello,
Many people are asking about how they can make expandable iFrames.
So i decided you give you all the code :)

Here's the IFRAME CODE:

<script type="text/javascript">
//<![CDATA[
window.onload = function() {
var f = document.getElementById("mainframe");
function resize() {
var h = "";
var w = "";
if (f.contentDocument) {
h = f.contentDocument.documentElement.offsetHeight + 20 + "px";
(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>

<iframe name="frm" id="mainframe" src="URL HERE" frameborder="0" allowtransparency="no" scrolling="no" target="_self" height="150"></iframe>

And here's the HTML code:

<a href="URL OF PAGE" target="content">Name Of Page</a>

Hope this helped,

Meti

Robbie
15-05-2008, 07:29 PM
Why have you put the link target as "content" when there is no frame called "content"

Meti
16-05-2008, 06:25 AM
:O I'm sorry. My misstake.
It should be

<a href="URL OF PAGE" target="I1">Name Of Page</a>

DUB
16-05-2008, 08:12 AM
Theres not a frame called that either lol.

But good tutorial :)

Meti
16-05-2008, 08:34 AM
<a href="URL OF PAGE" target="frm">Name Of Page</a>

That then? :P

--ss--
16-05-2008, 12:11 PM
That then? :P
Nope, the target frame should be called 'mainframe' as that's the frame the javascript will be looking for and expanding:

var f = document.getElementById("mainframe");

Independent
23-05-2008, 01:01 PM
There is no way you created that code, I know who did.

Are you using it with permission?

Invent
23-05-2008, 01:08 PM
There is no way you created that code, I know who did.

Are you using it with permission?

I agree that he should have permission if it wasn't released for free but it's not exactly the hardest thing to code is it, lol.

Agnostic Bear
23-05-2008, 07:00 PM
It's from Dynamic Drive, nobody even cares about that site anymore. They're the no. 1 supplier of annoying scripts to even more annoying people.

Meti
23-05-2008, 08:14 PM
It's from Dynamic Drive.
I took it a while ago, when i had my fansite going.

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