The transition from one page to some other with a space?

Here is the code to move the anchor to a specific location on the same page
$(document).ready(function () {
 $("#menu_contents").on("click", "a", function (event) {
event.preventDefault();
 var id = $(this).attr('href'),
 top = $(id).offset().top - 80 + "px";
$('body,html').animate({
 scrollTop: 1500
 }, top);
});
});


for this code in the Html there are links and id:
<ul id="menu_contents">
 <a href="#p1">
the <li>1.1</li>
</a>
 <a href="#p2">
the <li>1.2</li>
</a>
 <a href="#p3">
the <li>1.3</li>
</a>
</ul>


But how to make I was on the same page and marked a transition to another page in a certain place, but also became the indentation? Looking for lot of code, here's something similar found, but for some reason he knocks out bugs :(


Here I have is links to other pages with anchors :
<ul id="my_menu_contents">
 <a href="mechanics_lk/mechanics_lk1.html#p1">
the <li>1.1.</li>
</a>
 <a href="mechanics_lk/mechanics_lk1.html#p2">
the <li>1.2.</li>
</a>
 <a href="mechanics_lk/mechanics_lk1.html#p3">
the <li>1.3.</li>
</a>
</ul>
March 20th 20 at 11:30
2 answers
March 20th 20 at 11:32
when the page loads it is necessary to monitor # and if available to do the transition
can you please write exactly how this is done? what is to be done, I know). - lisette_Cole68 commented on March 20th 20 at 11:35
@Johnny.Haley,

https://www.site.com#section - Rey26 commented on March 20th 20 at 11:38
@Mariana_Littel47, I mean what kind of js - lisette_Cole68 commented on March 20th 20 at 11:41
@Johnny.Haleydid not really want to write, then people will help I'm sure :))

There are a couple of lines of code will cost. - Rey26 commented on March 20th 20 at 11:44
@Johnny.Haley, we need to understand jquery ^-)

;

$(document).ready(function () {
 var hashtag = window.location.hash;
 if (hashtag != ") {
 //scrole here
}
});
- odessa.Emmerich3 commented on March 20th 20 at 11:47
March 20th 20 at 11:34
As an option to compare document.referrer and document.url
I'm not good in js, can you please detail and code?). - lisette_Cole68 commented on March 20th 20 at 11:37
@Johnny.Haley,
judging by your code, you for js at all unrealistic even to take.
The basics of html)
<a href="mechanics_lk/mechanics_lk1.html#p1">
the <li>1.1.</li>
 </a>

the <li>
 <a href="mechanics_lk/mechanics_lk1.html#p1">1.1. </a>
</li>
- Oswaldo commented on March 20th 20 at 11:40
@Milford.Graham, Yes, I js did not study at all. and in the html the link has around li to li the whole paragraph was a link, not just the text inside the element).
5ccaf0f4a25ba511511060.png - lisette_Cole68 commented on March 20th 20 at 11:43
@Milford.Graham, unfortunately, this is irrelevant to my question... can you still help me to solve it, not the basics of html?). - lisette_Cole68 commented on March 20th 20 at 11:46
@Johnny.Haley, you have a validator with this code will clear the error. A block element inside of a string. Besides, sometimes it leads to build errors DOM.

If you want to link it all, do it inside li, and add in CSS: a { display: block; }. - Rey26 commented on March 20th 20 at 11:49

Find more questions by tags JavaScriptHTML