本文介绍了引用页面上的特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道在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()?
更多推荐
引用页面上的特定位置
发布评论