<script type="text/javascript" src="frontend/sea-modules/jquery/1.8.3/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="frontend/sea-modules/json/json2_2.js"></script>
<script type="text/javascript">
function clientA(event){
var url_param=event.data.split("|");
var url=url_param[0];
var param=JSON.parse(url_param[1]);
$.ajax({
type : "post",
url : url,
dataType : "json",
async : false,
data:param,
success : function(response) {
var resStr=JSON.stringify(response);
event.source.postMessage(resStr,'*');
window.removeEventListener('message', clientA);
console.log(event, event.data);
}
});
}
function clientB(event){
var url_param=event.data.split("|");
var url=url_param[0];
var param=JSON.parse(url_param[1]);
$.ajax({
type : "post
ie8对于onmessage 事件的监听和取消
最新推荐文章于 2024-03-13 01:04:44 发布
本文介绍了如何在 IE8 浏览器中使用 `postMessage` 进行跨域通信,并提供了针对 IE8 的事件监听(`attachEvent`)和移除(`detachEvent`)的示例代码。通过示例代码,展示了在接收到消息后进行 AJAX 请求并返回响应数据的过程。
摘要由CSDN通过智能技术生成