Can I call functions in a modeless dialog from the parent
February 3, 2012 9:38 AM   Subscribe

Is there anyway to call functions of a modeless dialog (in IE) from the parent window that spawned the dialog?

I'd like the user to be able to click on items in the parent window in order to change some data in the dialog upon which they can then perform actions.

Also I'm not quite sure what the difference is between opening a new window with window.open vs window.showModelessDialog and when I'd use one over the other.

Thanks!
posted by zeoslap to Computers & Internet (3 answers total)
 
Sure. Here's 2 pages. I've bolded the working parts.

mainPage.html
<html>
<head>
	<title>I am the main page</title>
</head>
<body>
<h1>I am the main page.</h1>
<p>I am data.</p>
<p><button onclick="window.showModelessDialog('dialogPage.html', window);">I am a button</button></p>
<p id="displayArea">I can be updated.</div>
</body>
</html>
dialogPage.html
<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>
</body>
</html>

posted by artlung at 12:36 PM on February 3, 2012


Response by poster: I was after the reverse of that - but thanks.
posted by zeoslap at 1:49 PM on February 3, 2012


Ok here's intercommunication in a Gist. Closer?
posted by artlung at 2:26 PM on February 3, 2012


« Older Is there an online platform that will let me post...   |   Please don't break, old beat-up car Newer »
This thread is closed to new comments.