PDA

View Full Version : Extenable iframe? =S



Puma
24-12-2006, 02:14 PM
I need help doing extenable iframe could someone give me a tutorial on this please or can someone help! xD

alarmclock
24-12-2006, 02:27 PM
Hey there,

There's no tutorial needed to make an expandable iframe. You have to get a Javascript code and insert it just before your 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";
// 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>
Just remember to name your iframe mainframe otherwise it won't work :P

Puma
24-12-2006, 02:34 PM
Hmm.. soo then my iframe html will be <iframe src="main.html" name="mainframe" width="" height="" frameborder="0"></iframe> ??

alarmclock
24-12-2006, 02:36 PM
yup :)

put id="mainframe" in there aswell, after name="mainframe"

Puma
24-12-2006, 02:37 PM
am really confuse atm >____< LOOL can you show me a example?

alarmclock
24-12-2006, 02:50 PM
thinkhabbo used to have it.

first you need a layout capable of expanding.

Nick.
24-12-2006, 02:52 PM
am really confuse atm >____< LOOL can you show me a example?

<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";
// 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>
<iframe src="main.html" name="mainframe" id="mainframe" width="" height="" frameborder="0"></iframe>

:)

Colin-Roberts
24-12-2006, 02:54 PM
example is on colin-roberts.net i use expandable iframes..

alarmclock
24-12-2006, 02:54 PM
Source always after the name and id Nick :eusa_naug


<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";
// 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>
<iframe name="mainframe" id="mainframe" src="main.html"
width="" height="" frameborder="0"></iframe>

Nick.
24-12-2006, 02:57 PM
Long time since I've done this stuff ;)

alarmclock
24-12-2006, 03:04 PM
It doesn't really matter, just makes it a cleaner code - hence xhtml.

Puma
24-12-2006, 03:24 PM
THanks lads =).. am goin to create a template and could you tell me if it capable or extenable iframe okies? =)

alarmclock
24-12-2006, 03:28 PM
Any template can if coded properly.

Frog!
28-12-2006, 07:30 PM
When i do it, the writing goes to the centre of the iFrame :(
Not at the top of the iFrame where it belongs.

F32
28-12-2006, 08:12 PM
When i do it, the writing goes to the centre of the iFrame :(
Not at the top of the iFrame where it belongs.
that's because the table you have it in isn't aligned properly.

in the <td> tag put <td valign="top">

Frog!
28-12-2006, 08:18 PM
Thanks, it worked a treat, +Rep

Recursion
28-12-2006, 08:20 PM
Just use Ajax on an expandable layout :P

F32
28-12-2006, 08:25 PM
Just use Ajax on an expandable layout :P
dont confuse even more - you dont need AJAX...

Recursion
28-12-2006, 08:27 PM
I know, i just like Ajax, they are very nice when you get them working in IE...

F32
28-12-2006, 08:28 PM
AJAX is a coding language thing...

Recursion
28-12-2006, 08:34 PM
I know, i accedentally used 'them'.

AJAX is a form of Javascript but it is still very nice when it works in all browsers...

ATM Ive only got it working in Firefox and Opera to change the content like an iframe, but not an iframe...

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