简体   繁体   中英

HTML page jump with anchor not working

I've got a really simple problem that I'm sure there is a simple fix for, but I just can't find it.

I'm trying to jump from one page to another using an anchor, in order to load the new page on a particular div. Obviously this doesn't work, instead the page just loads at the top.

This is what my <a> tag looks like:

<a href="projects.html#link" onclick="location.reload()" class="col-sm-4 
noHighlight">

Then, on the page "projects.html" I have this:

<div class="container" id="link" name="link">
<br>
<h2 style="text-align: center;">Test</h2>
<br>
<h5>
</h>
</div>

If, when the projects.html page has loaded, I force refresh my chrome browser tab, the page does load at the correct div. If I then scroll back to the top and force refresh the tab one more time, it doesn't work. The location.reload() was an attempt to force the browser to force refresh by itself, but nothing appears to change with or without it.

Any advice would be appreciated, If I need to post more code I will, but I don't really have much javascript or CSS that could be conflicting.

Thanks,

your boi, Boi.

将以下代码添加到您的子主题 CSS: html {scroll-behavior: auto !important;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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