Is there any method I can avoid the falter when i scroll down the scrollbar

Discussion in 'Javascript' started by jidixuelang@gmail.com, Jul 19, 2007.

  1. Guest

    Hi all!

    I create a div ,which i wish can stay top alway?I user onscroll to
    simulate this.

    But let me desponding,when scroll down the scrollbar,i can see the div
    is faltering distinctly!

    Is there any method I can use to avoid the falter?

    Please look the following code:

    Code:
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
    www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html,body{ margin:0;}
    #topDiv {
    width:100%;
    height:80px;
    background:#ccc;
    color:#fff;
    font-size:24px;
    font-weight:bold;
    text-align:center;
    }
    </style>
    </head>
    
    <body>
    <div id="topDiv">Is there any method I can avoid the falter when i
    scroll down the scrollbar?</div>
    <script type="text/javascript">
    function autoScrollDiv(id){
    this.dbody = document.getElementById(id);
    with(this.dbody.style){
    position= "absolute";
    top     = "0";
    left    = "0";
    }
    var control = this.dbody;
    window.onscroll	=  function(){
    var posY = document.documentElement.scrollTop ||
    document.body.scrollTop;
    control.style.top = posY + "px";
    }
    }
    /*
    autoScrollDiv.prototype = {
    autoScroll:function(){
    var posY = document.documentElement.scrollTop ||
    document.body.scrollTop;
    this.dbody.style.top = posY + "px";
    }
    }
    */
    var a = new autoScrollDiv("topDiv");
    </script>
    
    <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /[color=blue]
    ><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /
    ><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /
    ><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /
    ><br /><br /><br />[/color]
    </body>
    </html>
    
    
    
    
    
    
    
     
    , Jul 19, 2007
    #1
    1. Advertising

  2. Guest

    THX David!
    It only jitter "if lt IE 7",now!Great!
    But i ever see this effect in a website(http://blog.163.com/,you may
    see that in top left when you login.test
    username:avoidthefalter,password:aaa111 [number 1 not char l]) .
    I discover its code just like my write!
    But i didn't see the jitter in IE6,when i visit that website.
     
    , Jul 20, 2007
    #2
    1. Advertising

  3. David Mark Guest

    On Jul 19, 8:26 pm, "" <>
    wrote:
    > THX David!
    > It only jitter "if lt IE 7",now!Great!
    > But i ever see this effect in a website(http://blog.163.com/,youmay
    > see that in top left when you login.test
    > username:avoidthefalter,password:aaa111 [number 1 not char l]) .
    > I discover its code just like my write!
    > But i didn't see the jitter in IE6,when i visit that website.


    I don't know how that could be. Are you sure they weren't creating
    scrollable DIV's or using Flash or some other nonsense. I can't make
    heads or tails of that site as I don't have the required fonts (or
    Flash) installed.
     
    David Mark, Jul 21, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kurt Underhay

    Can't scroll horizontal scrollbar

    Kurt Underhay, Apr 11, 2005, in forum: Java
    Replies:
    1
    Views:
    2,125
  2. Kent
    Replies:
    1
    Views:
    402
    Irrwahn Grausewitz
    Sep 26, 2003
  3. Sathiamoorthy

    Enable Scroll up and scroll down in CR-report

    Sathiamoorthy, Nov 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    902
    zobalee
    Nov 28, 2006
  4. Alex

    ScrollBar? Does it exist just WEB ScrollBar Control?

    Alex, Apr 1, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    272
    Alvin Bruney [MVP]
    Apr 4, 2004
  5. jkarpago

    Is there any way to lock scrollbar?

    jkarpago, Aug 4, 2006, in forum: Javascript
    Replies:
    2
    Views:
    119
    jkarpago
    Aug 9, 2006
Loading...

Share This Page