SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    passing frame name??

    hello

    was using this as a frame scroll...


    var ps = parent.left;

    function movedown() {

    if (document.all && y < ps.document.body.scrollHeight || document.height && y < ps.document.height) {
    ps.scroll(0,y);
    y = y + 4;
    when = setTimeout('movedown()',1);
    }

    }


    which worked ok but need to change it so that i can pass the name of the frame to be scrolled for a general script. so i changed it to the following...


    function movedown(ps) {

    if (document.all && y < parent.frames[ps].document.body.scrollHeight || document.height && y < parent.frames[ps].document.height) {
    parent.frames[ps].scroll(0,y);
    y = y + 4;
    when = setTimeout('movedown()',1);
    }

    }


    this seems to do something when i pass movedown('left') but refuses to loop the script. any ideas anyone??

    a+
    Garrett

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bon jour Garrett, comme se va?

    You need to pass the argument:

    when = setTimeout('movedown(' + ps + ')',1);

    it needs to be written as above because setTimeout expects its first parameter to be a string. If you wrote it as:
    when = setTimeout('movedown(ps)',1);
    the assumption would be that ps is also a value and not a variable.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pas tres bien!
    so as i understand it should be like so....

    function movedown(frame) {

    if (document.all && y < parent[frame].document.body.scrollHeight || document.height && y < parent[frame].document.height) {
    parent[frame].scroll(0,y);
    y = y + 4;
    when = setTimeout('movedown(' + frame + ')',1);
    }

    }

    this does'nt work it moves 4 pixels on calling the function and never anymore, does'nt loop!!

    a+
    Garrett


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
  •