1、传参
function IframeClose() {
var obj = {method: "iframeClose"};
window.parent.postMessage(obj, "*");
} //删除
function deleteExercise(exeid) {
//删除习题:delExercise(习题id)
var obj = {method: "deleteExercise", exeid: exeid};
window.frames[0].postMessage(obj, domain);
}
2、接参
window.addEventListener('message', function (e) {
if (e.data.method == "iframeClose") {
Modal.Close("#ExerciseScoreIframe");
if (typeof iframecallback == "function") {
iframecallback();
} else {
window.location.reload();
}
}
}, false); window.addEventListener('message', function (e) {
if (e.data.removeLayout != undefined && e.data.removeLayout == "success") {
console.log("删除排版成功");
window.location.reload();
}
}, false);