Parent page (opener):
function getData()
{
var script = "<script type=\"text/javascript\">function runFunction(){alert('Hello world');}<\/script>";
return script;
}
function sendData(elem, data)
{
$(opener.document).find('#' + elem).append(data);
opener.document.runFunction();
}
// Listen to update parent
$(document).ready(function()
{
$("button[name='update']").click(function()
{
sendData('rss-block', getData());
});
});
</script>
Update Parent
Child page:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
// Listen to create editor
$(document).ready(function()
{
// Create editor
function loadEditor()
{
window.open('./editor.htm', 'rssEditor', 'width="50px"','height="50xp"');
}
$("button[name='edit']").click(function()
{
loadEditor();
});
});
</script>
</head>
<body>
<div id="rss-block">
<button name="edit">Edit</button>
<div>
</body>
</html>
The child needs to update the parent by appending the javascript to the parent rss-block and then the child needs to be able to execute the function appended.