我正在使用 EasyXDM 处理跨域通信,以便父母知道孩子的大小和孩子的位置。我已经开始调整尺寸了。问题是当我在 iframe 内导航时,我想将位置推回父级。
问题是,当我更改无法再次创建套接字的页面时,给了我VM87 Core.js:324 Uncaught Error: url is undefined or empty。
还有其他人遇到这个吗?
家长(消费者):
<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>
子(生产者)剃刀布局
<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>