Javascript href 导航到不属于我的另一个 url 然后自动滚动到 class

Javascript href navigate to a different url not owned by me then scroll to a class automatically

所以基本上我想创建一个像这样的 href <a href="https://www.some-website-i-do-not-own.com >Go to link and jump to class</a> 它会 link 到我不拥有的外部站点但我知道在那个页面的底部有一个div跟class我在DOM找到了一篇linking的文章。我不仅要重定向到此页面,还要自动让浏览器滚动到那个 div 的 class.

的 Y 位置

同样,我无法访问他们的任何代码,我通过 DOM 找到了这个 class,这可能吗?

通常通过添加

来完成

#id-of-element-to-scroll-to

到URL结束 以that为例

https://www.wikiwand.com/en/Stack_Overflow#Statistics

会将您重定向到他们的页面,然后滚动到 id="Statistics" 的元素

可以使用 ID 转到网站页面的特定位置。如果您知道位于要跳转到的位置的元素的 ID,则只需将其添加到 URL 的末尾,如下所示: <a href="https://www.some-website-i-do-not-own.com**#bottom**>Go to link and jump to class</a>

ID 以 # 开头,然后是元素 ID 的名称。 如果我帮助了你,你可以批准这个问题作为解决方案。 祝你有美好的一天 ;)