我也将此消息发布在github网站上(GitHub
我在Godaddy中遇到一个错误,这是我以前从未遇到过的问题。下面是日志输出和实际页面的URL。
https://okfadeawayhoops.com/exposure-testing我相信它是由“ about:srcdoc”引起的。
我相信代码在下面
```
<script type="text/javascript">
function clearCache(url) {
return url + (url.indexOf('?') > -1 ? '&' : '?');
}
var iframe;
var socket = new easyXDM.Socket({
onReady: function () {
iframe = document.createElement("iframe");
iframe.frameBorder = 0;
iframe.allowtransparency = true;
iframe.scrolling = 'no';
document.body.appendChild(iframe);
iframe.src = clearCache(easyXDM.query.url);
},
onMessage: function (url, origin) {
iframe.src = clearCache(url);
}
});
</script>
日志
- 15:39:07.243: easyXDM present on 'about:srcdoc
exposure.widgets.js:1008 - 15:39:07.246:easyXDM.Socket: constructor
exposure.widgets.js:1008 - 15:39:07.246:{Private}: preparing transport stack
exposure.widgets.js:1008 - 15:39:07.247:{Private}: resolved url 'https://basketball.exposureevents.com/widgets/intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue'
exposure.widgets.js:1008 - 15:39:07.248:{Private}: selecting protocol: 1
exposure.widgets.js:1008 - 15:39:07.248:easyXDM.stack.PostMessageTransport: constructor
exposure.widgets.js:1008 - 15:39:07.248:easyXDM.stack.QueueBehavior: constructor
exposure.widgets.js:1008 - 15:39:07.248:easyXDM.stack.PostMessageTransport: init
exposure.widgets.js:1008 - 15:39:07.248:{Private}: adding listener message
exposure.widgets.js:1008 - 15:39:07.248:{Private}: creating frame: https://basketball.exposureevents.com/widgets/intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1
exposure.widgets.js:1008 - 15:39:07.249:{Private}: HAS_NAME_PROPERTY_BUG: false
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.841: easyXDM present on 'https://basketball.exposureevents.com/widgets/intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.844: easyXDM.Socket: constructor
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.844: {Private}: preparing transport stack
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.844: {Private}: using parameters from query
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.845: easyXDM.stack.PostMessageTransport: constructor
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.846: easyXDM.stack.QueueBehavior: constructor
easyXDM.debug.js:303 Uncaught Error: url is undefined or empty
at getLocation (easyXDM.debug.js:303)
at new easyXDM.Socket (easyXDM.debug.js:1296)
at intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1:45
getLocation @ easyXDM.debug.js:303
easyXDM.Socket @ easyXDM.debug.js:1296
(anonymous) @ intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1:45
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.847:{Private}: firing dom_onReady
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.847:... deferred messages ...
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.847:easyXDM.Socket: constructor
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:{Private}: preparing transport stack
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:{Private}: using parameters from query
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:easyXDM.stack.PostMessageTransport: constructor
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:easyXDM.stack.QueueBehavior: constructor
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:... end of deferred messages ..
答案 0 :(得分:0)
我能够解决这个问题。
以下是Godaddy HTML元素的修复程序。我们需要使用有效的URL代替“ about”选项。
function getLocation(url){
if (!url) {
throw new Error("url is undefined or empty");
}
if (/^file/.test(url)) {
throw new Error("The file:// protocol is not supported");
}
if (/^about/.test(url)) {
url = window.top.location.href.toLowerCase().match(reURI);
}
var m = url.toLowerCase().match(reURI);
var proto = m[2], domain = m[3], port = m[4] || "";
if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
port = "";
}
return proto + "//" + domain + port;
}
这是针对Godaddy专门尝试动态地更新自己的iframe高度的,否则将在iframe上设置一个设置的高度。
function _window_onMessage(event){
var origin = _getOrigin(event);
trace("received message '" + event.data + "' from " + origin);
if (typeof (event.data) == "string") {
if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
}
}
}