引用页面上的特定位置

编程入门 行业动态 更新时间:2024-10-26 02:36:36
本文介绍了引用页面上的特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道在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()?

更多推荐

引用页面上的特定位置

本文发布于:2023-11-10 10:39:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575127.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!