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>

只使用一個 <script> 標籤。不要把這個檔案載入兩次。

你也可以自己放置元素:

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

show(options) ​

每個欄位都可以省略。

欄位屬性預設意義
displayTimedisplay-time5000卡片停留的毫秒數,時間到了會自己關閉
animationTimeanimation-time300進入與離開動畫的毫秒數
defaultClosedefault-closetruedisplayTime 結束時關閉
positionpositionbottom-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 是這個外框的選擇器。

交通、貨幣化。·Koin廣告網絡用戶指南