How to capture position of a div so that on page reload i can have that position

  • A+
Category:Languages

i wanted to capture the position of a scrolling capture area as shown in image below

How to capture position of a div so that on page reload i can have that position

so that on page reload any other scenario the state is preserved.

$(function(){     setInterval(function(){       window.location.reload();    },90000);    });
.container{   width:600px;   height:300px;  // background:red;   overflow-y:auto;   font-size:18px;   line-height: 40px;   padding-left: 14px;   position: relative; }  .center-band{     position: fixed;     z-index: 40;     width: 100%;     height: 70px;     background: #0000003b;     top: 50%;     transform: translate(-50%, -50%); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="container">   Lorem ipsum, dolor sit amet consectetur adipisicing elit. Adipisci sequi omnis officia, tempore nesciunt distinctio in inventore quia voluptate ducimus eius natus ex. Facilis excepturi distinctio sunt placeat deleniti error.      Lorem ipsum dolor, sit amet consectetur adipisicing elit. Earum iste architecto dolores tempora officia vero, repellendus ab voluptas, eveniet dolore, cumque aliquam cum quas facilis aspernatur molestias perferendis eum nesciunt!            Lorem ipsum dolor sit amet consectetur adipisicing elit. Eligendi fugiat impedit quam, sit, sapiente, provident praesentium beatae non nostrum optio repellendus porro laboriosam quidem ipsa itaque? Voluptatem quam pariatur dolorem.      Lorem ipsum dolor sit amet consectetur adipisicing elit. Error, quisquam similique distinctio, perferendis accusantium quidem voluptatum architecto nulla ad adipisci provident possimus voluptatem ut animi aliquid quo hic ab. Assumenda?               Lorem ipsum dolor sit amet consectetur, adipisicing elit. Fuga, sit corporis. Vitae facilis nesciunt alias consectetur rem, exercitationem, est possimus, beatae architecto suscipit expedita provident culpa. At eum sequi omnis      Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas cum quaerat numquam ex vero, neque aliquid totam, explicabo error suscipit eius. Earum beatae voluptatum cupiditate iusto saepe quidem deserunt magnam?         Lorem ipsum dolor, sit amet consectetur adipisicing elit. Commodi possimus excepturi dolores quasi, qui libero quia amet, ab facere quis nulla voluptatem, sunt necessitatibus! Animi voluptates quam minus odio excepturi!      <div class="center-band"></div> </div>

below is my codepen:

https://codepen.io/eabangalore/pen/jeKQwd/

Question: i'm trying to capture the position of band area, so that on page reload my text will be same

Please Help me, thanks in advance

 


Use:

Old Fascinated Way

As a document, is good to create a document structure of sections and titles. Every section may have an ID. So, you can use anchors to create URLS that points to specific page sections. You may create an internal navigation too using anchors. See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

<a href="#my-section-1">My section 1</a> <a href="#my-section-2">My section 2</a> <section id="my-section-1">   <h2>My section 1</h2>   <p>Lorem ipsum ...<p> </section> <section id="my-section-2">   <h2>My section 2</h2>   <p>Lorem ipsum ...<p> </section>

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: