简体   繁体   English

链接到另一页上带有一堆图像的锚点

[英]link to an anchor on another page with a bunch of images before it

I have a link to a dom element on another page, the problem is that dom element has a lot of images before it, so when navigate to that element, the page fist works as expected but than jump to anywhere before it. 我在另一个页面上有一个dom元素的链接,问题是dom元素之前有很多图像,因此当导航到该元素时,页面拳头可以按预期工作,而不是跳转到它之前的任何地方。 I think the issue is it first calculate the right position before images load, but than loaded images makes page longer than before so the target dom element is displayed at wrong place. 我认为问题在于它首先在图像加载之前计算出正确的位置,但由于加载的图像比以前更长的页面,因此目标dom元素显示在错误的位置。

Is there any way to avoid this happening? 有什么办法可以避免这种情况的发生?

did you try this? 你有尝试过吗?

$(function(){
  window.location.href = "#anchor_id";
});

this runs after all DOM Elements are loaded ready and scrolls down to that anchor 在所有DOM元素都已加载好并向下滚动到该锚点后运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM