Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript to make the page jump to a specific location

Tags:

I there a way in javascript to make the page jump to a specific location on the page, such as

<span id='jump_to_this_location'></span> 

I do not want to re=load page,

like image 741
roger rover Avatar asked Aug 25 '10 19:08

roger rover


People also ask

How do you jump to a specific section in JavaScript?

A simple and modern way to do this would be like this: document. getElementById("jump_to_this_location").

How do I scroll to a specific position in HTML?

The scrollTo() method scrolls the document to specified coordinates.

How do I make one page go to another page in JavaScript?

Answer: Use the JavaScript window. location Property If you want to redirect the user from one page to another automatically, you can use the syntax window. location. replace("page_url") .

How do you jump a div in HTML?

By prepending your href with # , you can target an HTML element with a specific id attribute. For example, <a href="#footer"> will navigate to the <div id="footer"> within the same HTML document. This type of href is often used to navigate back to the top of the page.


1 Answers

You can set the location.hash property, like this:

window.location.hash = "jump_to_this_location"; 

You can give it a try here.

like image 97
Nick Craver Avatar answered Sep 28 '22 14:09

Nick Craver