Tip: you can modify some code before running
<!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><title>Compatible with "back to top" floating effects of various browsers</title><meta http-equiv="content-type" content="text/html;charset=gb2312"><!--把下面代码加到<head>与</head>之间--><style type="text/css">* {Margin: 0; padding: 0;} html {_ overflow: hidden;} body {_ overflow: auto; height: 100%;} a {text-decoration: none ;} # div {background: # ccc; width: 400px; height: 1500px; text-align: center ;}# returntop {border: 1px # ccc solid; background: # F30; width: 80px; height: 30px; position: fixed; _ position: absolute; line-height: 30px; text-align: center; top: 0px; left: 0px; display: none; cursor: pointer ;}</style></head><body><!--把下面代码加到<body>与</body>之间--><div id="div">This is the top</div><div id="returntop">Back to top</div><script type="text/javascript">Var getDiv = document. getElementById ('returntop '); var n = 0; function scrollEvent () {var scrollTop=document.doc umentElement. scrollTop | document. body. scrollTop; if (scrollTop) {getDiv. style. display = "block";} else {getDiv. style. display = "none";} n = 1;} window. onscroll = scrollEvent; if (n = 0) {document. body. onscroll = scrollEvent;} function getWinSize () {var extends umentElement. clientWidth;} else {winHeight = document. body. clientHeight; winWidth = document. body. clientWidth;} var height = winHeight-50; var width = winWidth-100; getDiv. style. top = height + "px"; getDiv. style. left = width + "px";} getWinSize (); window. onresize = getWinSize;</script></body></html></td> </tr></table>
Tip: you can modify some code before running