1.动态加载iframe地址
ifr即iframe的id
host即iframe的src地址
window.onload=function(){
var obj=document.getElementById("ifr")
obj.contentWindow.location.href=host;
}
2.跨域获取iframe子页面的动态url
iframe页面中
window.addEventListener('message',function(rs){
var href=rs.data;
if(href !="" && href != host){
location.href=href;
}
});
子页面
window.parent.postMessage(window.location.href,"*");