Set page scroll position when loading MVC application page

I have an ASP.NET MVC application.

How to set page scroll position when loading a page at a certain point?

Can I do this with an anchor, if so, how?

Malcolm

+3
source share
2 answers

You just need to add # div-name at the end of the page address. Example:

Set page scroll position when loading MVC application page

Set page scroll position when loading MVC application page - page address

# 2249506 - div name

If you want to do this when the page is loaded, you can write JavaScript:

window.location = '#2249506';

Using jQuery when loading a document:

<script type="text/javascript">
    $(function() {
        window.location = '#div-name';
    });
</script>
+7

.

name, <a> HTML-. - . name . .

:

<a name="label">Any content</a>

:

<a href="#label">Any content</a>

# href (http://www.mywebsite.com/mypage#label).

:

HTML-:

<a name="tips">Useful Tips Section</a>

:

<a href="#tips">Jump to the Useful Tips Section</a>

:

<a href="http://www.w3schools.com/html_tutorial.htm#tips">Jump to the Useful Tips Section</a>
+1

Source: https://habr.com/ru/post/1732460/


All Articles