今天做了兩個實驗,主要是爲下一步的集成第三方域名做個鋪墊
js的跨域調
準備了兩個實現,一個是嵌套iframe實現,一個是通過發送302跳轉實現。
代碼1:
域1www.aaa.com
域2 www.bbb.com
域1
<html>
<head>
<script language="javascript" >
//document.domain='10.1.43.51';
</script>
</head>
<body>
<div id="result"></div>
<iframe id="ppt" name="passport" src="http://www.bbb.com/ppt.html"></iframe>
</body>
</html>
域2:
<html>
<head>
<script language="javascript" >
</script>
</head>
<body>
asdfadfad
<iframe src="http://www.aaa.com/mail123-2.html#status=0" id="sr" name="sr"/>
</body>
</html>
這個還在域1
<html>
<head>
<script language="javascript" >
//window.top.alert(document.location.hash);
window.top.document.getElementById('result').innerHTML = 'login success, passport params=' + document.location.hash;
</script>
</head>
<body>
mail123-2.html
<div id="test">init</div>
</body>
</html>
測試通過。
方案2:
iframe中外域站點發302跳回本站,跳N條只要最終回來,都能正確調用。
業務需求不說了, 留個筆記,免得過幾天忘記。