targetPageParams()

此方法允许您从请求代码外部将参数附加到全局 mbox。

在多个 mbox 调用中包含相同的一组参数时,此函数非常有用。该函数需由客户定义。它应返回一个只传递给全局 mbox 请求的参数数组。此函数可在加载at.js之前或在以下位置定义: 管理 > 实现 > 编辑 > 库标题.

您可以按照以下任一方式使用 targetPageParams() 函数将参数传递到 target-global-mbox:

  • 以与号 (&) 分隔的列表
  • 数组
  • JSON 对象

示例

以 & 符号分隔的列表(值必须进行 URL 编码):

function targetPageParams() {
    return "param1=value1¶m2=value2&p3=hello%20world";
}

数组(值不需要进行 URL 编码):

targetPageParams = function() {
     return ["a=1", "b=2", "c=hello world"];
};

JSON(值不需要进行 URL 编码):

targetPageParams = function() {
  return {
    "a": 1,
    "b": 2,
    "profile": {
        "age": 26,
        "country": {
          "city": "San Francisco"
        }
      }
  };
};
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3