1、新建一個.js文件fanhui.js,并保存到自己網站目錄http://www.49028c.com/wp-content/themes/twentyeleven/js代碼如下:
- var isie6 = window.XMLHttpRequest ? false : true; function newtoponload() {
- var c = document.getElementByIdx_x_x(“full”); function b() {
- var a = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; if (a > 0) {
- if (isie6) { c.style.display = “none”; clearTimeout(window.show); window.show = setTimeout(function () {
- var d = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; if (d > 0) {
- c.style.display = “block”; c.style.top = (400 + d) + “px” } }, 300) } else { c.style.display = “block” } }
- else { c.style.display = “none” } } if (isie6) { c.style.position = “absolute” } window.onscroll = b; b() }
- if (window.attachEvent) { window.attachEvent(“onload”, newtoponload) }
- else { window.addEventListener(“load”, newtoponload, false) }
- document.getElementByIdx_x_x(“full”).onclick = function () { window.scrollTo(0, 0) };
2、將下面的代碼復制到所用主題的footer.php文件,</body>標簽之后、</html>標簽之前的位置.
- <div id=”full” style=”width:50px; height:95px; position:fixed; left:49%; top:476px; margin-left:493px; z-index:100; text-align:center; cursor:pointer;”>
- <a><img src=”http://www.49028c.com/wp-content/uploads/2013/01/fanhui.jpg” border=0 alt=”返回頂部”></a>
- </div>
- <script src=”http://www.49028c.com/wp-content/themes/twentyeleven/js/fanhui.js” type=”text/javascript”>
- </script>
新聞熱點
疑難解答
圖片精選