使用给定的函数发布消息,但收到错误"DataCloneError:无法克隆该对象".at line"target ['postMessage'](message,target_url.replace(/([^:] +:// [^ /] +).*/,'$ 1'));" 在FireFox-34中,相同的代码在Chrome和旧版FireFox上运行良好.
var storage = function() {
return {
postMessage : function(message, target_url, target) {
if (!target_url) {
return;
}
var target = target || parent; // default to parent
if (target['postMessage']) {
// the browser supports window.postMessage, so call it with a targetOrigin
// set appropriately, based on the target_url parameter.
target['postMessage'](message, target_url.replace( /([^:]+:\/\/[^\/]+).*/, '$1'));
}
}
}
}();
Run Code Online (Sandbox Code Playgroud)