Skip to content

Instantly share code, notes, and snippets.

@TaopaiC
Last active October 10, 2015 21:37
Show Gist options
  • Save TaopaiC/320e9c4a7e0c0ecd402d to your computer and use it in GitHub Desktop.
Save TaopaiC/320e9c4a7e0c0ecd402d to your computer and use it in GitHub Desktop.
test page for postMessage to set modal size
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="test page for postMessage to set modal size">
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>Test page for postMessage to set modal size</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script>
function evalButton(event) {
event = event || window.event;
var target = event.target || event.srcElement;
event.preventDefault();
var content = target.innerText;
console.log('eval:', content);
eval(content);
}
function postMessage(data) {
if (window.parent === window) {
alert('not in an iframe');
} else {
var postData = JSON.stringify(data);
window.parent.postMessage(postData, '*');
}
}
</script>
</head>
<body>
<a class="btn btn-default" onClick="evalButton()" role="button">console.log('haha')</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', height: 'auto'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', height: '700'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', height: '500'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', height: '900'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', height: 'auto', width: 'auto'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', height: '700', width: '400'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', height: '700', width: '800'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', width: 'auto'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', width: '400'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'resize', width: '800'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'complete'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'close'})</a>
<a class="btn btn-default" onClick="evalButton()" role="button">postMessage({action: 'finish'})</a>
<h1>Lorem Ipsum is simply</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h1>Lorem Ipsum is simply</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h1>Lorem Ipsum is simply</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h1>Lorem Ipsum is simply</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment