blob: b35773ae92bb97fe51c7c67ebe15d1f16923e358 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
<!DOCTYPE html>
<html>
<!--
Copyright 2010 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<script type="text/javascript" src="../../../base.js"></script>
<script type="text/javascript">
goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.net.xpc.CrossPageChannel');
</script>
<script type="text/javascript">
var channel;
var logEl;
/**
* Writes a message to the log.
* @param {string} msg The message text.
*/
function log(msg) {
logEl || (logEl = goog.dom.getElement('log'));
var msgEl = goog.dom.createDom('div');
msgEl.innerHTML = msg;
logEl.insertBefore(msgEl, logEl.firstChild);
}
goog.events.listen(window, 'load', function() {
// Get the channel configuration from the URI parameter.
var cfg = goog.json.parse(
(new goog.Uri(window.location.href)).getParameterValue('xpc'));
// Create the channel.
channel = new goog.net.xpc.CrossPageChannel(cfg);
channel.registerService('log', log);
channel.connect(function() {
log('Channel connected.');
});
});
</script>
<style type="text/css">
body {
background-color: #ddffff;
font-family: arial,verdana;
font-size: 12px;
}
</style>
</head>
<body>
<h3><script type="text/javascript">document.write(location.href.replace(/\?.*/,'?...'))</script></h3>
<p>
<input type="text" id="msgInput" value="Hello from the iframe."
style="width:250px">
<input type="button" value="Send" onclick="
channel.send('log', goog.dom.getElement('msgInput').value)">
</p>
<div id="log" style="border: 1px #000 solid"></div>
</body>
</html>
|