頁面推送
指令碼: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>只使用一個 <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 必須是零或正數。其他值都改用預設值。
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 是這個外框的選擇器。