a.html
<script>
function openOther(v){
var w = showModalDialog("b.html");
v.val.value=w;
}
</script>
<form>
<input name="val">
<input type="button" onclick="openOther(this.form);" value="click">
</form>
<script>
function sopen(vv){
var w = showModalDialog("b.html");
w = w + "";
if( w != "undefined" ){
vv.v.value = w;
}
}
</script>
<form>
<input name="v">
<input type="button" onclick="sopen(this.form);" value="open">
</form>
b.html
<script>
function returnText(v){
window.returnValue = v.val.value;
window.close();
}
</script>
<form>
<input name="val">
<input type="button" onclick="returnText(this.form);" value="return">
</form>