页面推送
脚本: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)
每个字段都可以不传。
| 字段 | 属性 | 默认 | 含义 |
|---|---|---|---|
displayTime | display-time | 5000 | 卡片停留多久后自己关闭,单位毫秒 |
animationTime | animation-time | 300 | 进入和离开动画,单位毫秒 |
defaultClose | default-close | true | displayTime 结束时是否关闭 |
position | position | bottom-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 就是这个外层盒子的选择器。