父页面中的onclick怎么等待子页面的事件后在执行

父页面中的onclick如何等待子页面的事件后在执行?
我纯粹是个新手,请教一下,边问边学。

我有两个window,一个是index.html(主窗口), frame(辅助窗口),希望实现:在主窗口index.html点击图片打开新的窗口,然后在新窗口frame接受事件,随后在主窗口改变图片。

我的问题时:如何能在frame窗口返回后,再改变图片?

谢谢!

index.html 


<html>
<head>
<script type="text/javascript">

function changeImage(_element) { 
        var newpng = "./new.png";
        _element.setAttribute("src", newpng); 
}

function openwin(element) {
    var url = "http://localhost/imgonclick.html";
    var newWindow = window.open(url,'frame','width=100%,top=0,left=0,status=no');
    changeImage(element) 
}

</script>
</head>

<body>
<img id="jizi" src="./tian.png" width="100%"  onclick="openwin(this);" />
</body>
</html>


imgonclick.html


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
        <meta http-equiv="Content-Type" name="viewport" content="text/html, charset=utf-8, maximum-scale=1">
    </head>
<script type="text/javascript">

function choose() {
    window.opener.changeImage("something");
}

</script>

<body>
            <img width='240' src="./new.png" height='auto' width='auto' onclick='choose();'>
</body>
</html>

------解决思路----------------------
引用:
我测试了用一下,在这个例子中,子页面要用window.opener 来调用父页面的函数和变量。我想可能是因为在index.html中用frameset的缘故。使用frameset是为了照顾我的Iphone浏览器Safari.

在主页面中,<img src="./old.png" width="100%"  onclick="openwin(this);" /> 中的 this 是指的img整个对象吗?我在子页面中执行changeImage参数中应该没有这个对象。也不知道怎么才能在主页中click点击来触发继续执行那个changeImage.


子页面获取父页面元素直接赋值
window.parent.document.getElementById('img_id').src='aaaaaaaaaa.jpg'