Results 1 to 4 of 4

Thread: manual IFrame scroller

  1. #1
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question manual IFrame scroller

    I'm trying to get this Scrollable content II @ http://www.dynamicdrive.com/dynamicindex11/scrollc2.htm script to work with content in an IFrame.

    I want two seperate buttons (outside of the IFrame) to control the scrolling of the content within the IFrame.

    Is there a way to do this?

    Thanks
    BoLt

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

    Default

    Code:
    <input
      type="button"
      onclick="
        document.frames['myIFrame'].moveup();
      "
      value="Move up"
    />
    <input
      type="button"
      onclick="
        document.frames['myIFrame'].movedown();
      "
      value="Move down"
    />
    <input
      type="button"
      value="Stop"
      onclick="
        document.frames['myIFrame'].clearTimeout(document.frames['myIFrame'].moveupvar);
        document.frames['myIFrame'].clearTimeout(document.frames['myIFrame'].movedownvar);
      "
    />
    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!

  3. #3
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply Twey. I've found a script that worked pretty well for this.

    Here is what I did If anyone else has the same question.

    <script type="text/javascript">
    <!--
    scrollPos = 0
    speed=1
    scrollMe=""

    function scrollDown() {
    clearTimeout(scrollMe)
    scrollPos +=speed
    window.frames["frame1_name"].scrollTo(0,scrollPos)
    scrollMe=setTimeout("scrollDown()",50)

    if(scrollPos>window.frames["frame1_name"].document.body.scrollHeight - (parseInt(document.getElementById("frame1_id").style.height)-10)){

    scrollPos=window.frames["frame1_name"].document.body.scrollHeight - (parseInt(document.getElementById("frame1_id").style.height)-10)

    clearTimeout(scrollMe)

    }

    }

    function scrollUp() {
    clearTimeout(scrollMe)
    scrollPos -=speed
    window.frames["frame1_name"].scrollTo(0,scrollPos)
    scrollMe=setTimeout("scrollUp()",50)

    if(scrollPos<speed){
    scrollPos=0
    clearTimeout(scrollMe)
    }

    }

    function stopMe(){
    clearTimeout(scrollMe)
    }

    // -->
    </script>

    <iframe name="frame1_name" id="frame1_id" src="page1.htm" scrolling="no" frameborder="yes" style="height:100px"></iframe><BR> <a href="#null" onmouseover="scrollUp()" onmousedown="scrollUp(speed=5)" onmouseup="scrollUp(speed=1)" onmouseout="stopMe()">Up</a> <a href="#null" onmouseover="scrollDown()" onmousedown="scrollDown(speed=5)" onmouseup="scrollDown(speed=1)" onmouseout="stopMe()">Down</a>
    I've just replaced the (Up,Down) text with an image tag. Works like a charm. Hope this helps someone.

    BoLt

  4. #4
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi there,

    Wow that really a nice script!!!

    I have one question though.

    Is it possible to get the scrolling smoother if the speed is set to a higher degree?

    hope u have some ideas

    greetings
    alexan

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
  •