From a same domain iframe I want to create a new function and append it to the parent window and then invoke that function from either the iframe or the parent. Something like this.
parent.myFunction = function(){ ... }; myfunction;
is there a good way to do this?
You can do almost exactly what you did
parent.myFunction = function(){ ... };
parent.myfunction(); // calling the function in parent window
And from the parent window, you'll be able to do simply
myFunction();
从子窗口调用函数使用parent.myfunction();
parent.myFunction = function(){ ... }; parent.myfunction();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.