history3.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <head>
  9. <title>History Demo 3</title>
  10. <link rel="stylesheet" href="css/demo.css">
  11. <style>
  12. body {
  13. font-family: sans-serif;
  14. font-size: 83%
  15. }
  16. table {
  17. border: 1px solid #666;
  18. background: lightblue;
  19. margin: 1em auto;
  20. }
  21. td {
  22. text-align: center;
  23. padding: 0 0.5em 0.5em 0.5em;
  24. }
  25. .hidden-frame {
  26. height: 0;
  27. left: 0;
  28. position: absolute;
  29. top: 0;
  30. width: 0;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <p>This page demonstrates a goog.History object used in an iframe. Loading JS
  36. code in an iframe is useful for large apps because the JS code can be sent in
  37. bite-sized script blocks that browsers can evaluate incrementally, as they are
  38. received over the wire.</p>
  39. <p>For an introduction to the goog.History object, see <a
  40. href="history1.html">history1.html</a> and <a
  41. href="history2.html">history2.html</a>. This demo uses visible history, like
  42. the first demo.</p>
  43. <p>Try following the hash links below, or updating the location with your own
  44. tokens. Replacing the token will update the page address without appending a
  45. new history entry.</p>
  46. <p>
  47. Set #fragment<br>
  48. <a href="#first">first</a><br>
  49. <a href="#second">second</a><br>
  50. <a href="#third">third</a>
  51. </p>
  52. <p>
  53. Set Token<br>
  54. <button onclick="setToken('//\\\\/\\/\\');">//\\/\/\</button>
  55. <button onclick="setToken('{\'a\': \'123\', \'b\': \'456\'}');">
  56. {'a': '123', 'b': '456'}
  57. </button>
  58. <button onclick="setToken('!@#$%^&*()_+-={}[]\\|;\':&quot;,./<>?');">
  59. !@#$%^&*()_+-={}[]\|;':&quot;,./&lt;&gt;
  60. </button>
  61. <button onclick="setToken('%2F/foo');">%2F/foo</button>
  62. <button onclick="setToken('%20 02%');">%20&nbsp;&nbsp;&nbsp;02%</button>
  63. </p>
  64. <p>
  65. <input type="text" id="token_input">
  66. <button onclick="setToken()">Set Token</button>
  67. <button onclick="replaceToken()">Replace Current Token</button>
  68. </p>
  69. <table><tr><td>
  70. <h3>The current history state:</h3>
  71. <div id="token_output"></div>
  72. </td></tr></table>
  73. <p>The state should be correctly restored after you
  74. <a href="http://www.google.com/">leave the page</a> and hit the back button.</p>
  75. <fieldset class="goog-debug-panel">
  76. <legend>Event Log</legend>
  77. <div id="log"></div>
  78. </fieldset>
  79. <input type="text" id="hist_state" style="display:none">
  80. <iframe name="js" class="hidden-frame" src="history3js.html"></iframe>
  81. <script>
  82. function setToken(opt_val) {
  83. if (js && js.googHist) {
  84. var input = document.getElementById('token_input');
  85. js.googHist.setToken(opt_val || input.value);
  86. }
  87. return false;
  88. }
  89. function replaceToken() {
  90. if (js && js.googHist) {
  91. var input = document.getElementById('token_input');
  92. js.googHist.replaceToken(input.value);
  93. }
  94. return false;
  95. }
  96. </script>
  97. </body>
  98. </html>