栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

刷新页面并保持滚动位置

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

刷新页面并保持滚动位置

更新

您可以使用

document.location.reload(true)
下面提到的方法代替下面的强制技巧。

将HTML替换为:

<!DOCTYPE html><html>    <head>        <style type="text/css"> body {      background-image: url('../Images/Black-BackGround.gif');     background-repeat: repeat; } body td {    font-Family: Arial;     font-size: 12px;  } #Nav a {      position:relative;      display:block;      text-decoration: none;      color:black;  }        </style>        <script type="text/javascript"> function refreshPage () {     var page_y = document.getElementsByTagName("body")[0].scrollTop;     window.location.href = window.location.href.split('?')[0] + '?page_y=' + page_y; } window.onload = function () {     setTimeout(refreshPage, 35000);     if ( window.location.href.indexOf('page_y') != -1 ) {         var match = window.location.href.split('?')[1].split("&")[0].split("=");         document.getElementsByTagName("body")[0].scrollTop = match[1];     } }        </script>    </head>    <body><!-- BODY ConTENT HERE --></body></html>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/614771.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号