Wednesday, 21 October 2015

Scroll to top in visualforce page using jquery

Here is the sample scroll to top code using jquery,

  1. <apex:page showHeader="false">
  2. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  3.  
  4.     <style>
  5.     .scrollToTop{
  6.     width:100px;
  7.     height:80px;
  8.     padding:10px;
  9.     text-align:center;
  10.     background: whiteSmoke;
  11.     font-weight: bold;
  12.     color: #444;
  13.     text-decoration: none;
  14.     position:fixed;
  15.     bottom:5px;
  16.     right:0px;
  17.     display:none;
  18.     background: url('http://primetimenews.in/Images/scroll.png') no-repeat;
  19.     background-size: 60px 62px;
  20.  
  21. }
  22. .scrollToTop:hover{
  23.     text-decoration:none;
  24. }
  25. </style>
  26.  
  27. <script>
  28. $(document).ready(function(){
  29.    
  30.     //Check to see if the window is top if not then display button
  31.     $(window).scroll(function(){
  32.         if ($(this).scrollTop() > 400) {
  33.             $('.scrollToTop').fadeIn();
  34.         } else {
  35.             $('.scrollToTop').fadeOut();
  36.         }
  37.     });
  38.    
  39.     //Click event to scroll to top
  40.     $('.scrollToTop').click(function(){
  41.         $('html, body').animate({scrollTop : 0},800);
  42.         return false;
  43.     });
  44.    
  45. });
  46. </script>
  47.  
  48.   <apex:pageBlock title="Block 1">
  49.  
  50.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  51.      
  52.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  53.  
  54.   </apex:pageBlock>
  55.  
  56.     <apex:pageBlock title="Block 2">
  57.  
  58.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  59.      
  60.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  61.  
  62.   </apex:pageBlock>
  63.  
  64.     <apex:pageBlock title="Block 3">
  65.  
  66.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  67.      
  68.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  69.  
  70.   </apex:pageBlock>
  71.  
  72.     <apex:pageBlock title="Block 4">
  73.  
  74.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  75.      
  76.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  77.  
  78.   </apex:pageBlock>
  79.  
  80.     <apex:pageBlock title="Block 5">
  81.  
  82.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  83.      
  84.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  85.  
  86.   </apex:pageBlock>
  87.  
  88.     <apex:pageBlock title="Block 6">
  89.  
  90.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  91.      
  92.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  93.  
  94.   </apex:pageBlock>
  95.  
  96.     <apex:pageBlock title="Block 7">
  97.  
  98.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  99.      
  100.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  101.  
  102.   </apex:pageBlock>
  103.  
  104.      <apex:pageBlock title="Block 8">
  105.  
  106.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  107.      
  108.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  109.  
  110.   </apex:pageBlock>
  111.  
  112.      <apex:pageBlock title="Block 9">
  113.  
  114.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  115.      
  116.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  117.  
  118.   </apex:pageBlock>
  119.  
  120.      <apex:pageBlock title="Block 10">
  121.  
  122.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  123.      
  124.       jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. <br/><br/>
  125.  
  126.   </apex:pageBlock>
  127.  
  128.   <a href="#" class="scrollToTop"></a>
  129.  
  130. </apex:page>


No comments:

Post a Comment

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...