JS callback

Multi-page value transfer

Parent page operation

1. Pass in the callback identifier and the corresponding execution method on the page_address through the link or button execution
2. Do the closing action of the subpage

url=’/XXX/XX.html?callback=childrenCall’

//Parent page execution, data processing
function childrenCall(ObjVal){ debugger; console.log(ObjVal); }


Sub-page operation:

1. Check if there is a callback function.
Use the address bar.
2. Find the callback function of the parent page and make a judgment.
3. Call and execute the parent page callback function callback
= too("callback");//too is to get the address bar information after encapsulation The tool method
if ($.isFunction(window.parent.frames[0][callBack])) {//If it is a function, it is allowed to call the method of the parent page
window.parent callBack ;
}
4. Call the parent page method to close the child page
window.open.hide(); || close();

Guess you like

Origin blog.csdn.net/YHM_MM/article/details/106965707