IE6 compatible return top code

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

Appreciation

see CSS HTML jquery js Related articles for

Please specify that the original article of this website is reproduced from To be kicked , Link: https://103.126.210.91/articles/1626.html

Comment list (3)

  1. reply Enthusiastic netizens Enthusiastic netizens

    There are many problems

  2. It's too complicated

  3. I've been looking for it for a long time. Thank you for your analysis
    Welcome to my station, too

Add a comment

Hello! #Please fill in the information# determine

Reward the blogger for drinking water
 LOADING