请问如何控制页面,让屏幕显示页面想要呈现的部分,而不是从顶部开始?

lidongzhuo6 2009-04-24 02:04:16
比如打开一个帖子,屏幕直接显示4楼的内容。
...全文
194 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lidongzhuo6 2009-04-24
  • 打赏
  • 举报
回复
感谢1楼,我没表述清楚意思,感谢7楼,用你的方法应该能可以。
牙签是竹子的 2009-04-24
  • 打赏
  • 举报
回复
加个锚链接

比如
<a name="#4">4楼 </a>


然后链接这样:

www.xxx.com/test.html#4

就可以定位到4楼了.
lidongzhuo6 2009-04-24
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 Free_Wind22 的回复:]
你打开贴子不就是刷新了吗
[/Quote]
其实我的本意是这样的,可能举得例子不够恰当。
我写了个视频的网页
左侧是视频,右侧是按视频播放的时间升序排列的评论(在style="overflow-y: scroll"里面),我想实现:拖动视频的播放条到某一时间时,右侧评论跟着居中显示出来。现在,拖动拖动视频的播放条后的时间已经被我捕获到了,问题是如何根据这个时间(亦即评论部分的播放时间)把对应的这条评论在style="overflow-y: scroll"里面居中显示。如果刷新页面,视频就停了。。。。。
natineprince 2009-04-24
  • 打赏
  • 举报
回复
<html>
<head>
<script>
function a(){
var a=document.getElementById('a');
window.scroll(0,a.offsetTop)
}

</script>
</head>
<body onload="a()">
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input type='text' value='100' /><BR>
<input id='a' type='text' value='100' /><BR>
</body>
</html>


刚刚说错了...OFFSETTOP才对.
lidongzhuo6 2009-04-24
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 natineprince 的回复:]
拿到目标OFFSETHEIGHT
再设置SCROLL
[/Quote]
能说得再具体点吗?谢谢
2009-04-24
  • 打赏
  • 举报
回复
你打开贴子不就是刷新了吗
natineprince 2009-04-24
  • 打赏
  • 举报
回复
拿到目标OFFSETHEIGHT
再设置SCROLL
lidongzhuo6 2009-04-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 Free_Wind22 的回复:]
加个锚链接

比如
<a name="#4">4楼 </a>


然后链接这样:

www.xxx.com/test.html#4

就可以定位到4楼了.
[/Quote]
能否不用刷新页面的方式达到效果呢?
2009-04-24
  • 打赏
  • 举报
回复
加个锚链接

比如
<a name="#4">4楼</a>


然后链接这样:

www.xxx.com/test.html#4

就可以定位到4楼了.

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧