我收到了上述消息。 blaablaa显然不是实际的站点地址。我尝试过使用jsfiddle,但我仍然收到相同的消息。
// TRACK OUTBOUND LINKS
document.addEventListener("DOMContentLoaded", function() {
var trackOutboundLink = function(url) {
ga('send', 'event', 'outbound', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
}
var a = document.getElementsByTagName('a');
for(i = 0; i < a.length; i++){
if (a[i].href.indexOf(location.host) == -1 && a[i].href.match(/^http?s:\/\//i)){
a[i].onclick = function(){
trackOutboundLink(this.href);
}
}
}
});
// END
我做错了吗?我假设是,但我不知道是什么。感谢
答案 0 :(得分:0)
AHH
window.addEventListener('message',function(event){
// IMPORTANT: Check the origin of the data!
if (~event.origin.indexOf('https://jsfiddle.net')) {
// The data has been sent from your site
// The data sent with postMessage is stored in event.data
console.log(event.data);
} else {
// The data hasn't been sent from your site!
// Be careful! Do not use it.
return;
}
});
应该是iframe调用的src的一部分,而不是我想的。我不确定,但我现在找到了另一个例子