jQuery点击跟踪无法在iFrame上运行 [英] jQuery Click Tracking not working on iFrame

查看:97
本文介绍了jQuery点击跟踪无法在iFrame上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这是我的代码:

<script type="text/javascript">
    $('#Advertisement-1').click(function () { 
        alert("Ad Clicked!"); 
    });
</script>

<div id="Advertisement-1">
    <!-- PBBG Ads Zone Code Begin -->
    <center>
        <iframe src='http://www.pbbgads.com/ad.php?z=429&bg=000000' width='468' height='67' marginwidth='0' marginheight='0' hspace='0' vspace='0' frameborder='0' scrolling='no'></iframe>
    </center>
    <!-- PBBG Ads Zone Code End -->
</div>

现在,我的问题是当我点击广告时,它不会发送提醒。它只是在新窗口中打开广告。我有什么想法让点击事件发挥作用?

Now, my issue is when I click the ad, it doesn't send an alert. It just opens the ad in a new window. Any ideas how I can get the click event to work?

推荐答案

提醒的代码在父窗口和广告I中假设在iframe中,所以除非父页面和iframe在同一个域中,否则不可能。

The code to alert is in the parent window and the ad I suppose is inside the iframe so it is not possible unless the parent page and iframe are in same domain.

这篇关于jQuery点击跟踪无法在iFrame上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆