Page A contains an iframe. Some html code is as follows:
[Html]
<Div> <iframe name = "ifm" width = "100%" height = "829" id = "ifmApp" src = "B. asp? Co = 1 & tp = 5 & ut = 1 & id = & gd = 11 & gm = 1 & ar = 2 & sv = 0 "frameBorder =" 0 "marginWidth =" 0 "marginHeight =" 0 "scrolling =" no "> </div>
A page contains the following js scripts:
Www.2cto.com
[Javascript]
Var System = {
CloseFrame: function (){
Try {
Var frames = document. getElementById ("ifmApp ");
Var AppHelper = frames. contentWindow. AppHelper;
If (AppHelper! = Null & typeof (AppHelper) = "object" & typeof (AppHelper. CloseQuery) = "function "){
If (! AppHelper. CloseQuery () return;
}
} Catch (e ){
}
System. Close ();
},
Close: function (){
Document. body. removeChild (ifrm );
}
};
The B. asp page corresponding to iframe src, with js functions:
[Javascript]
Var Apphelper = {
CloseQuery: function (){
If (val = "1") return true;
Return false;
},
Close: function (){
If (parent! = Null & typeof (parent) = "object "){
Var System = parent. System;
If (System! = Null & typeof (System) = "object "){
If (System. Close! = Null & typeof (System. Close) = "function "){
System. Close ();
Return;
}
}
}
}
};
Parent page A, calling its own System. CloseFrame to call the function Apphelper. CloseQuery in ifrme
In Ifame, the B page calls the System. Close function in the parent window by calling its Apphelper. Close function.
Of course, there is A premise to implement such A simple call, that is, A and B need to be in the same domain.
From the pure soul