> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/advertisers/ru/kampanii/iframe-events.md).

# События iframe

Рекламодатели могут отслеживать события в своих объявлениях. Эти события программно управляются непосредственно в браузере клиента с помощью JavaScript.

## События

### creativeDisplayed

{% hint style="info" %}
Это доступно только для **Полноэкранное межстраничное объявление для десктопа** и **Полноэкранное межстраничное объявление для мобильных устройств** (*DFPI/MFPI*) кампании с форматом рекламы с **URL iframe** вариация.
{% endhint %}

Когда объявление отображается пользователю, в iframe отправляется сообщение с именем `creativeDisplayed`.

Вы можете отслеживать это событие внутри своего iframe, используя приведенный ниже скрипт, который добавляет обработчик события, чтобы перехватить отправленное сообщение, когда объявление отображается пользователю.

```html
<script>
        function readMessage(event) {
            console.log("readMessage event");
            console.log("origin: " + event.origin);
            console.log("data: " + event.data);
        }

        if (window.addEventListener) {
            // Для браузеров, соответствующих стандартам
            window.addEventListener("message", readMessage, false);
        } else {
            window.attachEvent("onmessage", readMessage);
        }
</script>
```

## Пример - полноэкранное межстраничное объявление

```html
<!DOCTYPE html>
<html>
<head>
    <!-- ЧАСТЬ СОБЫТИЯ -->
    <script>
        function readMessage(event) {
            console.log("readMessage event");
            console.log("origin: " + event.origin);
            console.log("data: " + event.data);
            var message = "Мы получили сообщение: '" + event.data + "' от '" + event.origin + "' (сейчас мы на iframe рекламодателя)";
            console.log(message);
            document.getElementById("received-message").innerHTML = message;
            // рекламодатель в IE хочет обновить некоторый элемент
        }
        if (window.addEventListener) {
            // Для браузеров, соответствующих стандартам
            window.addEventListener("message", readMessage, false);
        } else {
            window.attachEvent("onmessage", readMessage);
        }
    </script>
    <!-- КОНЕЦ ЧАСТИ СОБЫТИЯ -->
</head>
<body>
    <h1>Заголовок моего тестового iframe</h1>
    <p>Абзац моего тестового iframe</p>
    <p id="received-message">Ожидание сообщения</p>
</body>
</html>
```

<figure><img src="/files/b974321f9ae14b16a32dbc4833c10f0b8e95215a" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/advertisers/ru/kampanii/iframe-events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
