【发布时间】:2021-11-03 07:28:03
【问题描述】:
这是我在 html 文档中使用的简单视频标签脚本
var video = document.getElementById('video'); var documentTitle = 文档.title; var updateTitleForVideo = 函数(状态){ 如果(状态 === '可见') { 文档.title=文档标题; 返回; } document.title = documentTitle + '['+ state +']'; }; video.onpause = function() { updateTitleForVideo('暂停'); }; video.onplay = function() { updateTitleForVideo('播放'); }; document.addEventListener('visibilitychange' , function(){ var state = document.visibilityState; 如果(!video.paused){ 如果(状态 === '隐藏'){ 视频.暂停(); updateTitleForVideo('暂停'); } } 如果(!video.played){ 如果(状态 === '可见'){ 视频.play(); updateTitleForVideo('播放'); } } });【问题讨论】:
标签: javascript html sass