Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto scroll of page to specific element of HTML

Hi I have length jsp page and at the bottom of the page I have save button once I click the save button it will save the data to the server and once data is saved I load the same page again and I am displaying some information saying "Data is saved" at the bottom of the page.

My question is how can I load the page to show this message when page loads instead of loading page at its top.

<html>
<head></head>
<body>
<span> Hi </span>
.....................
.....................
.....................
.
.
.
.
.
.
//at the bottom of page
<span> Data Saved succefully</span>
</body>
</html>

So when I load the page I should see "Data Saved succefully" message.

like image 536
chaman shareef Avatar asked Sep 24 '13 10:09

chaman shareef


People also ask

How do you auto scroll to a section in HTML?

You can use . scrollIntoView() for this. It will bring a specific element into the viewport.

How do I scrollTo a specific element?

Use the href Property to Scroll to an Element in JavaScript href = "#"; location. href = "#myDiv"; Here #myDiv is the ID of the required <div> tag.

How do I scrollTo a specific div in HTML?

If you want to scroll the current document to a particular place, the value of HREF should be the name of the anchor to which to scroll, preceded by the # sign. If you want to open another document at an anchor, give the URL for the document, followed by #, followed by the name of the anchor.


1 Answers

You can simply assign an id to the span and can redirect to the current page with #your-id attached at the end of your url.

<a href="http://jsfiddle.net/tFcsP/show/#demo">Click to go</a>

Check this link http://jsfiddle.net/tFcsP/show/#demo

like image 174
Ashis Kumar Avatar answered Sep 28 '22 11:09

Ashis Kumar