Debian Codegraph @

closure-library/closure/goog/demos/history3.html

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