Solution to turning frame page address to cross-Origin

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.