Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: iFrame Slide Out

  1. #1
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default iFrame Slide Out

    Am I doing something wrong here?

    Code:
    <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
    Last edited by tech_support; 06-05-2006 at 02:04 AM.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  2. #2
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think and I hope you should better replace the iframe = ""; with iframe = 0;

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    The iframe variable is for the interval. So there's no difference if i change it i think

    **scratches head**
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  4. #4
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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().

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Purely technical fixes and cleanups:
    Code:
    <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.
    Last edited by Twey; 06-06-2006 at 04:52 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Oh Right.... Ooopss... My Bad....
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  7. #7
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Can I not have it onload? I want to have it open via a link.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Great script!!

    Great script tech_support and Twey!! Can this be done even with framesets??

  10. #10
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    You mean the slide out iframe script?

    With framesets it's already been done.

    See: http://www.dynamicdrive.com/forums/s...9&postcount=18
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •