Skip to content

页面推送 ​

脚本:https://koin-ad.click/page-push/v1/main.js

元素:<x-push>

全局对象:push

公共方法在 广告代码 API。页面推送额外有 show(options) 和四个属性。

接入 ​

需要卡片出现时调用 show()。它返回该元素;如果脚本没有注册元素名,则返回 null。

html
<script>
  function onKoinPush() {
    push.show({
      displayTime: 8000,
      position: 'bottom-left',
    });
  }
</script>
<script
  async
  src="https://koin-ad.click/page-push/v1/main.js?id=UNIT_ID"
  onload="onKoinPush()"
></script>

一个页面只用一条脚本。也可以自己放元素:

html
<x-push display-time="8000" position="bottom-left"></x-push>

show(options) ​

每个字段都可以不传。

字段属性默认含义
displayTimedisplay-time5000卡片停留多久后自己关闭,单位毫秒
animationTimeanimation-time300进入和离开动画,单位毫秒
defaultClosedefault-closetruedisplayTime 结束时是否关闭
positionpositionbottom-right屏幕角落

displayTime 和 animationTime 必须是 0 或正数。其他值用默认值。

default-close 接受 true、false、1 和 0。

position 只能是 top-left、top-right、bottom-left、bottom-right。其他值都会变成 bottom-right。

js
const card = push.show({
  displayTime: 0,
  defaultClose: false,
  animationTime: 200,
  position: 'top-right',
});

displayTime: 0 或 defaultClose: false 时,卡片会留着,直到访客关闭,或你调用 push.close()。

访客关闭时会先播放离场动画,再移除元素。push.close() 会立刻移除。

theme() 的名字 ​

名字选中
push<x-push> 元素
card卡片
cover图片
body文字区
title标题
subtitle描述
prompt行动文案
micro-label小标签
badge-icon徽章
svg-icon图标

卡片是 position: fixed,宽 380px,离所选角落 16px。push 就是这个外层盒子的选择器。

流量货币化 · Koin 广告联盟用户使用指南