引用页面上的特定位置 [英] Referring to a specific place on page

查看:77
本文介绍了引用页面上的特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在Javascript中 document.location.href =#my_id告诉浏览器从ID =my_id的元素开始显示相同的页面。
在这种情况下,地址栏中显示的地址采用以下格式: my_page_address#my_id



这是唯一指向页面上特定位置的方法吗?
我正在寻找一种不会在地址栏中显示 my_id 的方法。

解决方案

您是否试过 document.getElementbyId(my_id)。scrollIntoView()


I know that in Javascript document.location.href = "#my_id" tells the browser to display the same page starting from element with id="my_id". In this case, the address that appears in the address bar is in the following format: my_page_address#my_id

Is this the only method to refer to a specific place on a page ? I'm looking for a method that will not show my_id in the address bar.

解决方案

Have you tried document.getElementbyId("my_id").scrollIntoView()?

这篇关于引用页面上的特定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆