Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. body {background:black;color:white;}
  8. </style>
  9. <script src="jquery.js"></script>
  10. <script src="signal.js"></script>
  11. <script src="history.js"></script>
  12. <script src="history.adapter.js"></script>
  13. <script src="routes.js"></script>
  14. <script>
  15.  
  16. $(function(){
  17. // Prepare
  18. crossroads.addRoute('/test/{id}', function(id){
  19. console.log(id,'888888888888888');
  20. });
  21.  
  22. // Bind to StateChange Event
  23. History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
  24. var State = History.getState(); // Note: We are using History.getState() instead of event.state
  25. console.log(State);
  26. crossroads.parse(document.location.pathname + document.location.search);
  27. });
  28.  
  29. $("body").on("click","a[data-href]",function(e){
  30. e.preventDefault();
  31. History.pushState({state:1}, "State 1", "/test/3");
  32. });
  33. });
  34. </script>
  35. </head>
  36. <body>
  37. hi
  38. <a href="#">Test</a>
  39. <a href="/test/two">Test2</a>
  40. <a href="#" data-href="/test/three">Test3</a>
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement