首页 > 代码库 > 跨域访问

跨域访问

 

iframe方式嵌入页面的操作实验

 

实验

<html><body><h1>hi, this is a.html, frame below show b.html</h1><iframe src="http://localhost/b.html"></iframe><script type="text/javascript">        window.onload = function(){                console.log("a.html loaded");                var frame = document.getElementsByTagName("iframe");                console.log("frame src=http://www.mamicode.com/"+frame[0].src);                var binput = frame[0].contentDocument.getElementById("binput");                console.log("b.html binput value=http://www.mamicode.com/"+binput.value);        }</script></body></html>
<html><body><h1>hi, this is b.html. this page call by localhost domain.</h1><input id="binput" value="binput"/></body></html>