> 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/tutorials/zh/jiao-cheng/fa-bu-shang-jiao-cheng/tan-chu-ye-zhong-ding-xiang-shi-li.md).

# 弹出页重定向示例

以下页面列出了一系列使用场景，在这些场景中你可以使用 **重定向弹窗 URL** 弹窗的格式，在特定条件下触发广告。

## 在 Adblock 下投放弹窗

假设你不想使用 **内联 + 远程脚本** 版本的弹窗，你可以按照以下步骤操作：

{% stepper %}
{% step %}
创建一个 `.js` 文件，命名为 `ads.js` ，其中包含以下代码：

```js
isAdblockActive = false;
```

{% endstep %}

{% step %}
再创建一个名为 `domains.js` ，其中包含以下代码：

```js
let storedDomain = null;
fetch("https://ads.exoclick.com/adblock-domains.php")
  .then(r => {
    if (!r.ok) {
      throw new Error("网络响应不正常（" + r.status + "）");
    }
    return r.json();
  })
  .then(data => {
    if (data.success && data.domain) {
      storedDomain = data.domain;
    } else {
      logError("API 返回错误：" + (data.message || "未知错误"));
    }
  })
  .catch(err => {
    logError("请求失败：" + err.message);
  });
```

{% endstep %}

{% step %}
将这两个文件放到你网站的服务器上。然后，在你网站的 HTML 中添加以下内容：

```html
<script type="text/javascript">var isAdBlockActive=true;</script>
<script type="text/javascript" src="domains.js"></script>
<script type="text/javascript" src="ads.js" ></script>
<a id="rd" href="#" target="_blank">重定向域名</a>
<script>
var link = document.getElementById('rd');
link.addEventListener("click", function (){
	if (isAdBlockActive) {
	window.location.replace("https://" + storedDomain + "/v1/link.php?cat=&idzone=XXXXX&type=8&block=1");
      } else {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8");
      }
});
</script>
```

当用户点击 id 为 `rd`的链接时，Redirect Popunder 将会触发。然后，如果浏览器中启用了 Adblock， `isAdBlockActive` 将被设为 true，因为 `ads.js` 会被拦截，从而允许重定向弹窗使用从 `domains.js`获取的动态 adblock 域名。 `&block=1` 参数允许弹窗将流量注册为 Adblock。
{% endstep %}
{% endstepper %}

## 投放 SFW 广告

这个 `ex_av` 和 `block_ad_types` 参数可以添加到 Redirect Domain Popunder 中，用于将用户标记为已通过或未通过年龄验证，并屏蔽 NSFW 广告。

以下代码基于 [**如何使用 ExoClick 投放 SFW 广告**](/tutorials/zh/jiao-cheng/fa-bu-shang-jiao-cheng/serve-sfw-ads.md) ，并根据用户是否有 `userVerified` cookie 来加载 Redirect Domain Popunder，该 cookie 会在用户通过年龄验证后设置。

```html
<a id="rd" href="#" target="_blank">重定向域名</a>
<script>
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const link = document.getElementById('rd');
const verifiedUser = getCookie("verified_user");
link.addEventListener("click", function (){
  if (verifiedUser === "yes") {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8&ex_av=1");
    }
  else {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8&ex_av=2&blocked_ad_types=101");)
  }
});
</script>
```

## 当网站 URL 上包含特定参数时，屏蔽带有特定标签的广告系列

以下代码基于 [**如何使用 data-block-ad-types 动态屏蔽广告类型**](/tutorials/zh/jiao-cheng/fa-bu-shang-jiao-cheng/dynamically-block-ads-using-data-block-ad-types.md) ，并读取将要加载弹窗的 URL 中某个特定参数的值。这对于通过特定参数来识别流量来源的发布商来说非常有用。

在此示例中，我们查找的是名为 `utm_source` 的参数，而要屏蔽的标签是 **已验证的误报**:

```html
<a id="rd" href="#" target="_blank">重定向域名</a>
<script>
const link = document.getElementById('rd');
const pb = new URLSearchParams(window.location.search).get("utm_source");
link.addEventListener("click", function (){
  if (pb === YYYYYYYYYYY) { // YYYYY 对应发布商用来识别我们希望强制执行此屏蔽的流量来源的任意值
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8&blocked_ad_types=98");
    }
  else {
    window.location.replace("https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8");)
  }
});
</script>
```


---

# 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/tutorials/zh/jiao-cheng/fa-bu-shang-jiao-cheng/tan-chu-ye-zhong-ding-xiang-shi-li.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.
