PDA

View Full Version : iFrame Slide Out



tech_support
06-05-2006, 01:58 AM
Am I doing something wrong here?



<script>
var iframe = ""

function iframe_slide() {

if (document.getElementById("quiz").style.height == 500) {

clearInterval('iframe')
}
else {

var currentheight = document.getElementById("quiz").style.height
document.getElementById("quiz").style.height = currentheight + 1

}
}

iframe = setInterval("iframe_slide()",1)
</script>


Help me please!

I want to slide out an iFrame

shachi
06-06-2006, 06:50 AM
I think and I hope you should better replace the iframe = ""; with iframe = 0;

tech_support
06-06-2006, 06:56 AM
The iframe variable is for the interval. So there's no difference if i change it i think

**scratches head**

shachi
06-06-2006, 03:55 PM
There is a difference because "" is a string and 0 is not a string. For e.g in js and any other scripting languages "1" and 1 are not the same. If you want it to make the same then you should use parseInt().

Twey
06-06-2006, 04:43 PM
Purely technical fixes and cleanups:
<script type="text/javascript">
var iframe = window.setInterval(
function() {
var quiz = window.document.getElementById("quiz"),
quizht = parseInt(quiz.style.height);
if(isNaN(quizht))
quiz.style.height = "0px";
else if (quizht >= 500)
window.clearInterval(iframe);
else
quiz.style.height = (quizht + 1) + "px";
},
10
);
</script>
shachi: He's right on this one. The variable is overwritten straight away, before it's ever used, by the window.setInterval() call. While this isn't a particularly neat way to do it, it should function well enough.

tech_support
06-07-2006, 06:33 AM
Oh Right.... Ooopss... My Bad....

tech_support
06-07-2006, 06:40 AM
Can I not have it onload? I want to have it open via a link.

djr33
06-07-2006, 07:13 AM
Yeah.

Call the function with <a onClick="function()"> and remove onLoad from the body tag. I don't actually see the body tag in the above codes, but I'm assuming that part just wasn't included if you're talking about onLoad.

shachi
06-07-2006, 08:10 AM
Great script tech_support and Twey!! Can this be done even with framesets??

tech_support
06-08-2006, 11:24 PM
You mean the slide out iframe script?

With framesets it's already been done.

See: http://www.dynamicdrive.com/forums/showpost.php?p=37849&postcount=18

shachi
06-09-2006, 07:43 AM
But does that slide out? If yes then thanks if no then thanks anyways.:p

tech_support
06-09-2006, 08:10 AM
Yes!

It does slide in and out and it's based by the collapsible frame script.

shachi
06-09-2006, 10:39 AM
Ooh awesome let me try that out. By the way is there any instructions for installation??

tech_support
06-10-2006, 05:54 AM
Just follow these instructions but instead of the normal script copy it with the modified script :)

Instructions: http://www.dynamicdrive.com/dynamicindex8/collapseframe.htm

Script: http://www.dynamicdrive.com/forums/showpost.php?p=37849&postcount=18

Modified by: jscheuer1 ( No surprises there! :) )

And thanks to jscheuer1 for modifying the script for me!