ASP.NET - How to set focus to bottom of page when you click on link button using javascript?

Asked By rajeev chandra on 23-Oct-12 01:45 AM
How to set focus to bottom of page when clicking on link button in asp.net using javascript?

I know how to do in server side but i want to do in client side only (to avoid postback)

Please help me asap
Danasegarane Arunachalam replied to rajeev chandra on 23-Oct-12 02:21 AM
Here is the Example

<html>
  <head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
    function goToByScroll(id){
        $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
    }
    </script>
  </head>
  <body>
  <ul>
    <li><a href="javascript:void(0)" onClick="goToByScroll('1')">Go to anchor 1</a></li>
    <li><a href="javascript:void(0)" onClick="goToByScroll('2')">Go to anchor 2</a></li>
    <li><a href="javascript:void(0)" onClick="goToByScroll('3')">Go to anchor 3</a></li>
    <li><a href="javascript:void(0)" onClick="goToByScroll('4')">Go to anchor 4</a></li>
  </ul>
  <div style="width:600px">
    <div id="1">
    <h1>1</h1>
     
  jQuery attempts to retrieve the elements specified by the
  selector before calling the .live() method, which may be time-consuming on large documents.
  Chaining methods is not supported.
   For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected.
  Since all .live() events are attached
  at the document element, events take the longest and slowest possible path before they are handled.
  On mobile iOS (iPhone, iPad and iPod Touch)
   the click event does not bubble to the document body for most elements and cannot be used with .live() without applying one of the following workarounds:
    Use natively clickable elements such as
    </div>
    <div id="2">
    <h1>2</h1>
     
  jQuery attempts to retrieve the elements specified by the
  selector before calling the .live() method, which may be time-consuming on large documents.
  Chaining methods is not supported.
   For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected.
  Since all .live() events are attached
  at the document element, events take the longest and slowest possible path before they are handled.
  On mobile iOS (iPhone, iPad and iPod Touch)
   the click event does not bubble to the document body for most elements and cannot be used with .live() without applying one of the following workarounds:
    Use natively clickable elements such as
    </div>
    <div id="3">
    <h1>3</h1>
     
  jQuery attempts to retrieve the elements specified by the
  selector before calling the .live() method, which may be time-consuming on large documents.
  Chaining methods is not supported.
   For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected.
  Since all .live() events are attached
  at the document element, events take the longest and slowest possible path before they are handled.
  On mobile iOS (iPhone, iPad and iPod Touch)
   the click event does not bubble to the document body for most elements and cannot be used with .live() without applying one of the following workarounds:
    Use natively clickable elements such as
    </div>
    <div id="4">
    <h1>4</h1>
 
  jQuery attempts to retrieve the elements specified by the
  selector before calling the .live() method, which may be time-consuming on large documents.
  Chaining methods is not supported.
   For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected.
  Since all .live() events are attached
  at the document element, events take the longest and slowest possible path before they are handled.
  On mobile iOS (iPhone, iPad and iPod Touch)
   the click event does not bubble to the document body for most elements and cannot be used with .live() without applying one of the following workarounds:
    Use natively clickable elements such as
    </div>
  </div>
  </body>
</html>
Danasegarane Arunachalam replied to rajeev chandra on 23-Oct-12 02:22 AM
Hemanth Kumar replied to rajeev chandra on 23-Oct-12 08:37 AM

Try this method and let me know

function scrollme(){
   dh=document.getElementById("frame1").document.body.scrollHeight
   ch=document.getElementById("frame1").height
  if(dh>fh){
         moveme=dh-fh
         frame1.window.scrollTo(0,moveme)
      }
}