当前位置:网站首页>laravel-admin 用 原生JS实现声音提示,及自动播放
laravel-admin 用 原生JS实现声音提示,及自动播放
2022-06-26 10:04:00 【siner.li】
本内容是在laravel-admin HomeController.php 内书写的
html部分
<h3><span class='label' id="onejs">$data[0]
<audio id="sound" autoplay="autoplay"></audio>
</span></h3>
JS部分
<script >
var onejs = document.getElementById('onejs');
var sound = document.getElementById("sound");
setInterval(function () {
// '/' 后面跟请求路径, data 为请求参数
$.get("/",function(data){
if ((data > 0) && (onejs.innerHTML < data)){
sound.src="/tip.mp3";
}
onejs.innerHTML = data;
});
},5000);
</script>
自动播放音频
必须要有页面的交互动作, 对于谷歌浏览器来说
html部分
<span class='label' id="onejs">$data[0]
<audio id="sound" muted autoplay src="/tip.mp3"></audio>
</span>
js部分
var onejs = document.getElementById('onejs');
var sound = document.getElementById("sound");
setInterval(function () {
$.get("/help",function(data){
if ((data > 0) && (onejs.innerHTML < data)){
sound.muted=false
sound.play()
}
onejs.innerHTML = data;
});
},5000);
边栏推荐
- Character sets and comparison rules
- Is it safe to open an account in the school of Finance and business?
- 搜索引擎高级搜索方法记录
- RDB持久化验证测试
- The sixth MySQL job - query data - multiple conditions
- SSH, SCP command appears permission denied, please try again solution
- Basic MySQL
- The difference between NPM and yarn
- Server single and two-way adjustable one key mutual trust script!
- MySQL performance monitoring and SQL statements
猜你喜欢

滑动窗口

Nuxt. JS - learning notes

Swiftui development experience: data layer of application design for offline priority

Fabric.js 上划线、中划线(删除线)、下划线

Win10 start FTP service and set login authentication

JS reverse | four libraries and one platform response data encryption

Express (I) - easy to get started

Grain Mall - distributed Foundation

OpenCV图像处理-灰度处理

Postman入门教程
随机推荐
MySQL 8th job
Is it safe for compass software to buy stocks for trading? How to open an account to buy shares
Introduction to sysbench Basics
JS reverse | four libraries and one platform response data encryption
Pit record_ TreeSet custom sorting results in less data loss
2021 Q3-Q4 Kotlin Multiplatform 使用现状 | 调查报告
8-图文打造LeeCode算法宝典-最小栈与LRU缓存机制算法题解
June training (the 26th day) - collective search
Quantitative investment learning - Introduction to classic books
See how I store integer data in the map < string, string > set
appliedzkp zkevm(8)中的Plookup Table
Notes - simple but adequate series_ KVM quick start
MySQL seventh job - update data
Character sets and comparison rules
MySQL backup and restore command
Grain Mall - distributed Foundation
Common interview questions of binary tree
Oracle11g 启动数据库时报错 ORA-27154: post/wait create failed
Common regular expressions - tool classes (mobile number, email, QQ, fax)
MySQL 10th job - View