0

更新的问题

我想要的是,当您每次点击广告(链接)时,您都会收到“点击!”的警报。

但是当我运行代码时,它说:

未捕获的安全错误:阻止具有源“null”的框架访问跨域框架。

请在此处查看代码http://jsfiddle.net/0pmofzty/23/

focus();
var parent = document.activeElement;
var iframe = document.getElementsByTagName('iframe')[0],
    iframeDoc = iframe.contentWindow.document;
var targetLinks = iframeDoc.getElementsByTagName('a');

var listener = addEventListener('blur', function() {
	if(document.activeElement === targetLinks) {
    alert("clicked!");
    focusParentEl();
	}
});

function focusParentEl() {
	iframe.blur();
	parent.focus();
  if(document.activeElement !== parent) {
  	setTimeout(focusParentEl, 500);
  }
}
<div id="container">
  <script>
    ll_r = "phinoy";
    ll_hc = "#545454";
    ll_tc = "#545454";
    ll_cc = "#e89d2b";
    ll_dc = "#7f8091";
    ll_w = "";
    ll_nf = "0";
    ll_nc = "0";
    ll_nh = "0";
    ll_nm = "0";
    ll_np = "0";
    ll_pa = "0";
    ll_nt = "0";
    ll_wt = "1";
    ll_fw = "1";
    ll_n = "6";
    ll_cl = "";
    ll_s = "w";
  </script>
  <script src="//www.leadsleap.com/w/js.js"></script>
</div>

这个片段是安全的。我从名为 Leadsleap 的广告公司获得脚本,这是一个不同的域。

4

0 回答 0