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

J

jidixuelang

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>

[QUOTE]
<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 />[/QUOTE]
</body>
</html>
 
J

jidixuelang

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.
 
D

David Mark

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top