scroll

Discussion in 'JavaScript' started by dean5000v, Jun 4, 2008.

  1. #1
    ok when i click on a link within a iframe it links fine but starts at the bottom of a page, is there any javascript like javascript:scroll(0,0) or something i can add into the header of my file so that it allways scrolls from the top of the page.
     
    dean5000v, Jun 4, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use
    
    document.body.scrollTop = 0; 
    document.body.scrollLeft = 0;
    Code (markup):
     
    xlcho, Jun 4, 2008 IP
  3. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i added that into the javascript which i have already in my document which is.

    <!--
    window.onload=montre;
    function montre(id) {
    var d = document.getElementById(id);
    if (d) {d.style.display = (d.style.display == 'block')? 'none': 'block';}
    for (var i = 1; i<=10; i++) {
            if (document.getElementById('smenu'+i) && document.getElementById('smenu'+i) != d) {document.getElementById('smenu'+i).style.display='none';}
        }
    }
    document.body.scrollTop = 0; 
    document.body.scrollLeft = 0;
    //-->
    Code (markup):
    but doesn't work have i done n e thing wrong ?
     
    dean5000v, Jun 4, 2008 IP