拦截 iframe 中内容的点击

发布于 2024-08-18 05:12:43 字数 226 浏览 4 评论 0原文

我有一个 iframe,它引用一个外部 URL,该 URL 提供包含 Flash 广告的页面。

我需要跟踪客户点击其中一个广告的频率。

我采用的方法是在 iframe 上渲染一个 div 元素。这允许我拦截点击事件,但是我需要将该点击传递给 iframe。使用 JavaScript 可以实现这一点吗?

I have an iframe that references an external URL that serves up pages that contain Flash adverts.

I need to track how often a customer clicks on one of those adverts.

The approach I am taking is to render a div element over the iframe. This allows me to intercept the click event, however I need to pass that click down to the iframe. Is this possible using JavaScript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

安穩 2024-08-25 05:12:43

不,这是不可能的。您无法在 JavaScript 中模拟真实点击,只能触发点击事件。

No, it's not possible. You can't simulate a real click in javascript, you can only fire click events.

树深时见影 2024-08-25 05:12:43

我认为这也是不可能的,

但是,假设点击将用户重定向到广告网站,您可以使用重定向拦截用户点击。使用一些唯一的广告 ID 更改您自己的服务器上某些脚本的链接。注册点击并将用户重定向到广告页面。

另一种可能性是使用此技术加载 iframe 的内容,这样您就可以知道查看广告的客户数量。但这当然可能是您的广告客户不喜欢/想要的广告方案。

I do not think that it is possible as well

But, assuming that the clicks redirect the user to the site of the advert, you could intercept the user click using redirections. Change the link to some script on your own server with some unique advert id. Register the click and redirect the user to the advertisement page.

Another possibility is to use this technique to load the contents of the iframe, so you known the amount of customers viewed the advertisement. But this of course might be an advertisement scheme your advertisement customer does not like/want.

南街女流氓 2024-08-25 05:12:43

您无法通过任何合法方式传递点击,并且如果您尝试以任何方式伪造它,您都会遇到跨域问题。我绝对会远离任何看起来像 点击劫持 解决方案的东西 - 它肯定会停止工作(也感觉很邪恶)。

您也许能够破解某些东西,具体取决于它的准确性。这将涉及跟踪当用户将鼠标放入横幅区域然后离开页面时发生的事件序列(推断他们点击了广告)。您可能会错过一些,也可能会发现一些误报。

它的工作方式类似于:

  1. 将覆盖的 div 留在
  2. onMouseOver 上,隐藏 div 并设置一个
    onbeforeunload 事件处理程序
    通过 AJAX 帖子(或类似的)注册“点击”,
  3. 当鼠标移出横幅区域时,

这意味着他们没有点击广告,因此再次显示 div 并删除我猜你会得到的 事件处理程序大约 80-90% 的准确度,但您必须在很多浏览器上进行测试。它还假设广告加载到同一窗口而不是新窗口中。如果它加载到一个新的那么我认为它会更加困难。

You can't pass the click through by any legitimate means, and you'll run up against cross-domain problems if you tried to fake it in anyway. And I would definitely stay away from anything that looks like a clickjacking solution - it's bound to stop working (and feels evil too).

You may be able to hack something, depending on how accurate it has to be. This would involve tracking the sequence of events happening when user has put their mouse into the banner area and then left the page (inferring that they clicked on the ad). You'll miss some, and you may catch some false positives too.

It would work something like:

  1. Leave the covering div in place
  2. onMouseOver, hide the div and set an
    onbeforeunload event handler that
    registers a "click" through an AJAX post (or similar)
  3. when the mouse moves out of the banner area it means they didn't click the ad, so show the div again and remove the event handler

I'd guesstimate you'd get about 80-90% accuracy, but you're going to have to test on a lot of browsers. It's also assuming the ad loads into the same window and not a new one. If it loads into a new one then I think it's going to be even harder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文