Advertisement
viktormorales

jQuery y Hotkeys: Cambiar página web con el teclado

May 27th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.71 KB | None | 0 0
  1. <head>
  2. ...
  3. <script type="text/javascript" src="RUTA/jquery.min.js"></script>
  4. <script type="text/javascript" src="RUTA/hotkeys.js"></script>
  5. <script>
  6. /** NAVIGATION */
  7. $(function(){
  8.     $(document).bind('keydown', 'right', function() {
  9.         var url = $('.next, a[rel="next"]').attr('href');
  10.             if (url)
  11.                 window.location = url;
  12.     });
  13.     $(document).bind('keydown', 'left', function() {
  14.             var url = $('.prev, a[rel="prev"]').attr('href');
  15.             if (url)
  16.                 window.location = url;
  17.         });
  18. });
  19. </script>
  20. ...
  21. </head>
  22. <body>
  23. <a href="http://miblog.com/page/2" class="prev">Página Anterior</div>
  24. <a href="http://miblog.com/page/4" class="next">Página Siguiente</div>
  25. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement