Created
February 3, 2012 22:25
-
-
Save artlung/1733294 to your computer and use it in GitHub Desktop.
Communicating between pages with window.showModelessDialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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