SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2005
    Location
    Place d'Italie
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face scrollBy of <iframe> not compatible with Firefox

    Hye, guys.
    I have used scrollBy to create a verticle scrolling effect of <iframe>
    This is the codes:
    Code:
    <script language="javascript">
    var TO;
    var dis=0;
    function scroll() {
      document.ifr.scrollBy(0,dis);
    }
    function scrollup() {
      dis=-20
      TO=setInterval("scroll()",200);
    }
    function scrolldown() {
      dis=20
      TO=setInterval("scroll()",200);
    }
    </script>
    Code:
    <a id="up" href="#" onmouseover="scrollup()" onmouseout="clearInterval(TO)" alt="Précédant"></a>
    <a id="down" href="#" onmouseover="scrolldown()" onmouseout="clearInterval(TO)" alt="Suivant"></a>
    <iframe name="ifr" src="saveur_chinois_iframe.htm" scrolling="no"></iframe>
    And here the online effect

    Well it works in IE, but the disappointing thing is it works only in IE, at lleast not in Firefox.
    I suspect that the method scrollBy is only valid for IE. But donn't know an alternative.
    Please help me if you know that.

  2. #2
    SitePoint Guru
    Join Date
    Feb 2005
    Posts
    602
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The iframe and the window of the iframe are different objects. To get the iframe window, do iframe.contentWindow.

    So: document.ifr.contentWindow.scrollBy

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2005
    Location
    Place d'Italie
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Maian
    The iframe and the window of the iframe are different objects. To get the iframe window, do iframe.contentWindow.

    So: document.ifr.contentWindow.scrollBy
    Sorry, that makes the function totally failed.

  4. #4
    SitePoint Guru
    Join Date
    Feb 2005
    Posts
    602
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give the iframe an id, and use document.getElementById(id). I think the document.name notation only works for form elements.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2005
    Location
    Place d'Italie
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, yes, it turns on in Firefox.
    Thanks a lot


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
  •