Not long ago small railway station A code returning to the top is added, but since I haven't paid attention to the browsing of IE6, I haven't found it. The original IE6 is incompatible with the returning to the top. In IE6, where it appears, it is a multi cup event at the bottom and bottom of the page.
At first, I struggled back to the top, which was fixed in the upper right corner of the copyright information. Later, I saw that many forums had such a code, so I tried to figure out how to steal it. After all, it was a JS application Well, I'm sure I won't write it. Stealing is a little bit better. Huan Yin despises me. Ha ha~~~
IE7 and above browser versions are completely compatible, but IE6, an old thing, is such a torment. It can't be handled alone.
The JS code I currently use is very simple, and also uses Jquery. It's needless to say that Jquery is loaded externally. The JS code is as follows:
< script type = "text/javascript" src = " http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js " >< /script>
< script type = "text/javascript" >
backTop = function ( btnId ){
var btn = document . getElementById ( btnId );
var d = document . documentElement ;
window . onscroll = set ;
btn . onclick = function (){
btn . style . display = "none" ;
window . onscroll = null ;
this . timer = setInterval ( function (){
d . scrollTop -= Math . ceil ( d . scrollTop * zero point one );
if ( d . scrollTop == zero ) clearInterval ( btn . timer , window . onscroll = set );
}, ten );
};
function set (){ btn . style . display = d . scrollTop ? 'block' : "none" }
};
backTop ( 'gotopbtn' );
< /script>
The HTML code is simpler:
<div id="gotopbtn">Return to the top</div>
The other is CSS rendering. See the CSS code:
< style type = "text/css" >
#gotopbtn { width : 20px ; height : 50px ; line-height : 999px ; overflow : hidden ; background : url(images/scrolltop.png) no-repeat fifty % zero ; position : fixed ; _ position : absolute ; bottom : 100px ; left : fifty % ; margin-left : 440px ; display : none ; cursor : pointer }
</ style >
<! -- [ if lt IE six ]>
< style type = "text/css" >
html { _ text - overflow : ellipsis }
#gotopbtn { _ position : absolute ; _ top : expression ( eval ( document . documentElement . scrollTop + four hundred ))}
</ style >
<! [ endif ] -- >
If lt IE 6 is displayed under the original judgment IE6. The detailed judgment rules can be seen here
Text overflow: ellipsis is to solve the problem of image jitter in IE6. Picture download, you know, I will not provide If necessary, please contact alone OK, So far, the function of returning to the top has been perfectly compatible with IE6, and I went to sleep