| <! 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> achieve dynamic display back to the top or not </title> <Style> /* Return to the top */ . Back_top {width: 45px; height: 45px; background: url(back_top_new.png) 0 0; position: fixed; left: 50%; margin-left: 500px; bottom: 105px; display: none ;} . Back_top: hover {background: url (images/back_top_new.png) 0-46px ;} </Style> </Head> <Body> <A title = "Back to Top" href = "javascript: void (0)" class = "back_top"> </a> <Script src = "js/jquery-1.11.0.min.js"> </script> <Script> Var mousewheelevt = (/Firefox/I. test (navigator. userAgent ))? "DOMMouseScroll": "mousewheel"; // FF doesn' t recognize mousewheel as of FF3.x If (document. attachEvent) // if IE (and Opera depending on user setting) Document. attachEvent ("on" + mousewheelevt, function (e ){ Var Tsung document.body.scrolltop+document.doc umentElement. scrollTop; If (t = 0 ){ $ (". Back_top" ).css ("display", "none "); } Else { $ (". Back_top" ).css ("display", "block "); } }); Else if (document. addEventListener) // WC3 browsers Document. addEventListener (mousewheelevt, function (e ){ Var Tsung document.body.scrolltop+document.doc umentElement. scrollTop; If (t = 0 ){ $ (". Back_top" ).css ("display", "none "); } Else { $ (". Back_top" ).css ("display", "block "); } }, False ); </Script> </Body> </Html> |