Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (66 sloc) 2.61 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="zh-tw">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Cross Frame Prototype</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssreset/reset-min.css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssfonts/fonts-min.css">
<style type="text/css">
body {
padding: 10px;
}
h1 {
margin-top: 20px;
font-family: Georgia;
font-size: 123.1%;
font-weight: bold;
}
iframe {
border: solid 3px #ccc;
}
</style>
</head>
<body>
<h1>Domain: josephj.com</h1>
<a href="http://josephj.com/project/yui3-crossframe/demo.html">Reload Page</a>
<div>
<iframe id="foo-iframe" src="http://josephjiang.com/project/yui3-crossframe/iframe.html" name="foo" width="500" height="500" border="3" frameborder="3"></iframe>
</div>
<script type="text/javascript" src="yui-debug-fix.js"></script>
<script type="text/javascript" src="crossframe.js"></script>
<script type="text/javascript">
YUI().use("json-parse", "event-custom", "node", "querystring-parse", "json-stringify", "crossframe", function (Y) {
var postMessage = function () {
var region = Y.one("#foo-iframe").get("viewportRegion"),
frameName = "frames['foo']",
config = {
"proxy" : "http://josephjiang.com/project/yui3-crossframe/proxy.html",
"reverseProxy" : "http://josephj.com/project/yui3-crossframe/proxy.html",
"eventType" : "crossframe:test1"
},
message = Y.JSON.stringify({
"host" : location.host,
"url" : location.href,
"referrer" : document.referrer,
"winHeight": region["height"],
"winWidth" : region["width"]
});
Y.log("josephj.com\n\nSend cross-frame message:\n\n" + Y.JSON.stringify(message) + "\n\nto window.frames['foo']");
Y.CrossFrame.postMessage(frameName, message, config);
};
postMessage();
Y.one("#foo-iframe").on("load", function (e) {
Y.log("josephj.com\n\n<iframe/> Load Event");
postMessage();
});
Y.one("window").on("resize", function (e) {
postMessage();
});
Y.on("windowresize", function (e) {
Y.log("josephj.com\n\n<iframe/> Resize Event");
postMessage();
});
});
</script>
</body>
</html>