admin管理员组文章数量:1188224
I am calling the parent function like window.parent.functionname();
from the child page. How can i call the window.child.function()
from the parent page to child page.
Any help is appreciated.
I am calling the parent function like window.parent.functionname();
from the child page. How can i call the window.child.function()
from the parent page to child page.
Any help is appreciated.
Share Improve this question edited Dec 19, 2012 at 13:25 Bergi 664k159 gold badges1k silver badges1.5k bronze badges asked Dec 19, 2012 at 13:20 JonathanJonathan 1,6699 gold badges35 silver badges55 bronze badges 4 |4 Answers
Reset to default 11Give your iFrame an id and try
document.getElementById("iFrameId").contentWindow.functionname()
This works even when you have multiple iFrames in the same page irrespective of their order.
Do you have an iframe?
Do something like that:
window.frames[0].contentDocument.functionname();
Parent page
var windowRef = null;
function openChildWindow() {
if ((windowRef != null) && (windowRef.closed == false)) {
if (windowRef.closed == false) windowRef.close();
windowRef = null;
}
var windowUrl = 'ChildPage.aspx';
var windowId = 'NewWindow_' + new Date().getTime();
var windowFeatures = 'channelmode=no,directories=no,fullscreen=no,' + 'location=no,dependent=yes,menubar=no,resizable=no,scrollbars=yes,' + 'status=no,toolbar=no,titlebar=no,' + 'left=0,top=0,width=400px,height=200px';
windowRef = window.open(windowUrl, windowId, windowFeatures);
windowRef.focus();
// Need to call on a delay to allow
// the child window to fully load...
window.setTimeout(callChildWindowFunction(), 1000);
}
function callChildWindowFunction() {
if ((windowRef != null) && (windowRef.closed == false)) windowRef.childWindowFunction();
}
Child Page
function childWindowFunction() {
alert('Hello from childWindowFunction()');
}
var win = null;
function openAndCall(id){
if (win!=null && win.closed==false){
win.close();
}
win = window.open("/somePage");
win.onload = function(){
win.callSome(id);
};
}
本文标签: framesHow can i call a window child function in javascriptStack Overflow
版权声明:本文标题:frames - How can i call a window child function in javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738383543a2084069.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
window.parent
and it's working, then you have an iframe. – jbabey Commented Dec 19, 2012 at 13:29tabbar.setHrefMode("iframes-on-demand"); tabbar.setContentHref("a1", "../../MailContactMain/Index");
Then can i call using a1 id – Jonathan Commented Dec 19, 2012 at 13:30