Mainframe.htm has two IFRAME values: Left. aspx on the left, leftframe on the frame, and mainframe on the right.
Left. aspx contains many connections. linka and linkc are connected to a page under the oa.shrcoa.gov.cn domain name, And linkb is connected to a page under the contact.shrcoa.gov.cn domain name,
Left. aspx has scripts for redirection, parent. frames ['mainframework']. frameelement. src = '.... '; when you click linka and then click linkc, there is no problem. In the same domain,
However, after you click linka, click linkb, and then click linkc to reject the access request. It should be cross-origin. The solution is as follows:
Left. aspx load script. jquery script is used here.
$ (Function (){
Loadscript ('scripts/nav. js ');
});
The loadscript is defined on the page where Paren needs to be referenced, that is, left. aspx.
VaR lastscript;
VaR H = Document. getelementsbytagname ("head") [0];
Function loadscript (URL ){
VaR F = Document. createelement ("script ");
VaR d = new date (). gettime ();
F. type = "text/JavaScript ";
F. ID = D;
F. src = URL + '? '+ D;
H. appendchild (f );
If (lastscript & G (lastscript) g (lastscript). parentnode. removechild (G (lastscript ));
Lastscript = D;
}
Function g (x) {return document. getelementbyid (x )};
-- ===================================================== ======================================
The content of NAV. JS is as follows in a website with left. aspx:
Function NAV (URL ){
// Parent. Frames ['mainframework']. frameelement. src = URL;
Parent. navig (URL); // here parentrefers to mainframe.htm
}
The loaded script is called every time a link in left. aspx is clicked:
NAV (O. hrefs );
If you write a function in mainframe.htm and call it on your own page, you will not get it wrong:
Function navig (URL ){
Document. Frames ["mainframe"]. Location. href = URL;
}