我使用EasyXDM来处理跨域通信,以便父级知道子级的大小和子级的位置。我已经把尺寸调整好了。问题是当我在iframe中导航时,我想将位置推回父服务器。
问题是,当我更改页面时,套接字无法再次创建,给出了VM87 Core.js:324未定义的错误: url是未定义的或空的。
还有人碰到这个吗?
父母(消费者):
<script language="javascript">
(function () {
// CTOR has side effect of creating globals for socket
var socket = new easyXDM.Socket({
remote: "@(Model.Url)" + document.location.hash,
container: $("#pluginFrame")[0],
onMessage: function (message, origin) {
var messageAsObject = JSON.parse(message);
if (messageAsObject.height) {
$("#pluginFrame iframe").height(messageAsObject.height);
}
if (messageAsObject.path) {
document.location.hash = messageAsObject.path;
}
},
onReady: function() {
console.log("Shell Socket Ready");
$("#pluginFrame iframe").width("100%");
}
});
})();
</script>儿童(制作人) Razor布局
<script language="javascript">
(function () {
debugger;
var socket = new easyXDM.Socket({
onReady: function () {
console.log("eBox Ready");
socket.postMessage(JSON.stringify({
height: $(".body-content").outerHeight(),
path: document.location.pathname
}));
}
});
$("body-content")
.on("change",
function () {
socket.postMessage(JSON.stringify({
height: $(".body-content").outerHeight()
}));
});
$(document.location.pathname)
.on("change",
function () {
socket.postMessage(JSON.stringify({
path: document.location.pathname
}));
});
socket.postMessage(JSON.stringify({
path: document.location.pathname
}));
})();
</script>发布于 2016-09-26 18:40:04
从我所见的一切来看,没有办法做我想要做的事。对于我最终试图解决的问题,将路由推入父节点的位置散列,似乎唯一的解决方案是使用这里提到的双iframe方法。
https://stackoverflow.com/questions/39578440
复制相似问题