jQuery实现跨域iframe接口方法调用
cross.js
http://localhost:8088
Cross.call(ifw,"http://localhost:8088","test",{t: $("#txt").val()});
}
</script>
</head>
<body>
<input id="txt" type="text"/>
<button onclick="call_b()">call</button>
<iframe id="ifr" src="http://localhost:8088/b.html"></iframe>
</body>
</html>
b.html
<!doctype HTML>
<html>
<head>
<script src="jquery-1.8.3.min.js"></script>
<script src="cross.js"></script>
<script>
//对外公开一个接口命名为test
Cross.on("test", function(data){
alert(data.t);
});
</script>
</head>
<body>
</body>
</html>
以上就是本文所述的iframe跨域的解决方案了,希望大家能够喜欢。
«
»