Learning Curve…

Archive for the ‘Javascript’ Category

1. Vertical Scoll position at the bottom of screen

<script type=”text/javascript”>

    function init() {

      var scnWid, scnHei;

      scnWid = document.body.clientWidth;

      scnHei = document.body.clientHeight;

      self.scrollTo(scnWid, scnHei);

    }

    window.onload = init;

  </script>

2. Vertical Scroll position based on a control in the screen

    Below example set scroll position at the start of grid’s header

<script type=”text/javascript”>

    function init() {

      var scnWid, scnHei;

      scnWid = getElementPosition(‘gridName’).left;

      scnHei = getElementPosition(‘gridName’).top;

     self.scrollTo(scnWid, scnHei);

    }

    function getElementPosition(elemID) {

      var offsetTrail = document.getElementById(elemID);

      var offsetLeft = 0;

      var offsetTop = 0;

      while (offsetTrail) {

        offsetLeft += offsetTrail.offsetLeft;

        offsetTop += offsetTrail.offsetTop;

        offsetTrail = offsetTrail.offsetParent;

      }

      return { left: offsetLeft, top: offsetTop };

    }

    window.onload = init;

  </script>


Author

Learning days (Calendar)

June 2017
M T W T F S S
« Jun    
 1234
567891011
12131415161718
19202122232425
2627282930  

Knowledge Bank (Archives)

I am on Twitter

Blog Stats

  • 498,681 hits

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 43 other followers

%d bloggers like this: