Skip to content

Instantly share code, notes, and snippets.

@artlung
Created February 3, 2012 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artlung/1733294 to your computer and use it in GitHub Desktop.
Save artlung/1733294 to your computer and use it in GitHub Desktop.
Communicating between pages with window.showModelessDialog
<html>
<head>
<title>I am a dialog page</title>
<script>
window.onload = function(){
document.getElementById('updateButton').onclick = function(){
var openerWindow = window.dialogArguments;
var dialogValue = document.getElementById('someText').getAttribute('value');
openerWindow.document.getElementById('displayArea').innerHTML = dialogValue;
};
};
</script>
</head>
<body>
<h1>I am a dialog page</h1>
<p><input type="text" value="Some Text." id="someText"></p>
<p><button onclick="" id="updateButton">Update</button></p>
<p id="displayArea">I can be updated.</div>
</body>
</html>
<html>
<head>
<title>I am the main page</title>
<script>
var childDialog = false;
var myNumber = 100;
</script>
</head>
<body>
<h1>I am the main page.</h1>
<p>I am data.</p>
<p><button onclick="childDialog = window.showModelessDialog('dialogPage.html', window)">Open Child</button></p>
<p id="displayArea">I can be updated.</div>
<p><button onclick="if(childDialog){childDialog.document.getElementById('displayArea').innerHTML = myNumber;myNumber+=10;}">Update Child</button></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment