javascript parent and child window
I have a page that uses javascript and opens a child window which updates some fields in the parent window.
Now the fields that are updated have a onchange()
function I want the child window to call this function when updating the field.
Is this possible using javascript?
EDIT:
My Code:
This is the link that opens the child window:
<a href="javascript:void(0);" style="width:100%; height:125%" onclick="window.open('otherExpenses.php','R开发者_开发知识库atting','width=350,height=550,left=50,top=50,toolbar=1,status=1,');">Open Child</a>
And in the child window, some operations are done with user interaction, then this is how the child is closed:
<a href="javascript:void(0);" onclick="post_value()">Close Child</a>
And the post_value()
function:
function post_value()
{
opener.document.overHeads.overheadOther.value = document.otherExpenses.TextBox27.value;
opener.document.overHeads.hiddenOther.value = document.otherExpenses.TextBox27.value;
//here I want to call a function from the parent window that updates some field in the parent window.
self.close();
}
to answer your question: "Is this possible using javascript?"
yes
you'll need to post some more code if you want a better answer.
If the function belongs to the parent window, you have to attach it to the child window from the context of the parent window:
//w is the child window
w.document.getElementById('theId').onchange(window.somefunction);
精彩评论