IFRAME cross-domain (level two domain name)

Source: Internet
Author: User

There are a.ceshi.com to load b.ceshi.com content through the IFRAME, through the two sub-domain pages under the same settings Document.domian set to the same primary domain can be achieved across the domain read data:

A.ceshi.com page

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"Xml:lang= "en"><Head>    <Metahttp-equiv= "Content-type"content= "Text/html;charset=utf-8">    <title>Ceshi1</title></Head><Body>I was 1 .<DivID= "Box1"></Div><Scripttype= "Text/javascript">//set the primary domainDocument.domain= 'ceshi.com';variframe=Document.createelement ("iframe"); Iframe.style.display= 'None';//Pull b.ceshi.com Contentiframe.src= "http://b.ceshi.com";d Ocument.body.appendChild (iframe);//Determine if loading is completeif(iframe.attachevent) {iframe.attachevent ("onload", function() {alert ("Local iframe is now loaded."); Alert (Iframe.contentWindow.document.body.innerHTML) document.getElementById ('Box1'). InnerHTML=Iframe.contentWindow.document.body.innerHTML; }); } Else{iframe.onload= function() {alert ("Local iframe is now loaded."); Alert (Iframe.contentWindow.document.body.innerHTML) document.getElementById ('Box1'). InnerHTML=Iframe.contentWindow.document.body.innerHTML; }; }</Script></Body></HTML>

B.ceshi.com page

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"Xml:lang= "en"><Head>    <Metahttp-equiv= "Content-type"content= "Text/html;charset=utf-8">    <title>Ceshi2</title></Head><Body>I was 2 .<Scripttype= "Text/javascript">//set the primary domainDocument.domain= 'ceshi.com';</Script></Body></HTML>

This allows you to read the contents of b.ceshi.com from a.ceshi.com.

As far as through the IFRAME across different primary domain names, to be continued ...

IFrame cross-domain (level two domain name)

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.