Skip to content

监听网页 show、hide、enter、leave 事件

Notifications You must be signed in to change notification settings

yorkjs/web-page

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web-page

监听网页 showhideenterleave 事件。

安装

CDN

<script src="https://unpkg.com/@yorkjs/web-page"></script>

NPM

npm install @yorkjs/web-page

YARN

yarn add @yorkjs/web-page

示例

import * as WebPage from '@yorkjs/web-page'
WebPage.addEventListener(
  WebPage.SHOW,
  function (data) {
    console.log('show', data)
  }
)
WebPage.addEventListener(
  WebPage.HIDE,
  function (data) {
    console.log('hide', data)
  }
)
WebPage.addEventListener(
  WebPage.ENTER,
  function (data) {
    console.log('enter', data)
  }
)
WebPage.addEventListener(
  WebPage.LEAVE,
  function (data) {
    console.log('leave', data)
  }
)

API

init()

初始化。

addEventListener(type, listener)

监听事件,仅支持对外暴露的常量事件。

兼容性

  • showhide 事件仅适用于支持 visibilitychange 事件的浏览器。
  • enterleave 事件仅适用于支持 pageshowpagehide 事件的浏览器。

About

监听网页 show、hide、enter、leave 事件

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published