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.
You can use . scrollIntoView() for this. It will bring a specific element into the viewport.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With