基于JavaScript实现报警器提示音效果
作者:祈澈姑娘 时间:2024-04-22 13:24:43
原型图:
项目需求:
服务器接受到报警后将消息推送到前台,(通过前端实时消息提示的效果-websocket长轮询),前台接受到消息后需要发出警报提示音,提醒用户。
原理:
很简单,使用html5里面的<audio>标签即可实现,在铃声的官网上选择一段报警的音频,放在代码里面即可。
代码片段:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<audio autoplay="autoplay" id="auto" src=""></audio>
<input type="button" value="点击播放" onclick="playSound('http://data.huiyi8.com/2017/gha/03/17/1702.mp3')">
</body>
<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
<script>
$(function(){
function playSound(src) {
var auto = $("#auto");
auto.attr("src",src);
}
})
</script>
</html>
</script>
</html>
总结
以上所述是小编给大家介绍的基于JavaScript实现报警器提示音效果网站的支持!
来源:http://www.jianshu.com/p/97334d7bfb98?utm_source=tuicool&utm_medium=referral
标签:js,报警器,提示音
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
浅谈Python 命令行参数argparse写入图片路径操作
2023-03-18 21:08:11
![](https://img.aspxhome.com/file/2023/3/82643_0s.jpg)
Tensorflow2.10实现图像分割任务示例详解
2021-08-31 13:14:47
![](https://img.aspxhome.com/file/2023/1/114511_0s.png)
Python3.4学习笔记之类型判断,异常处理,终止程序操作小结
2022-06-03 10:45:54
IE6局部调用PNG32合并图片
2009-03-11 21:24:00
![](https://img.aspxhome.com/file/UploadPic/20093/11/01-12s.jpg)
python编写softmax函数、交叉熵函数实例
2023-11-24 07:08:11
![](https://img.aspxhome.com/file/2023/6/64606_0s.jpg)
快速理解MySQL中主键与外键的实例教程
2024-01-26 16:16:57
SQL Server 磁盘请求超时的833错误原因及解决方法
2024-01-14 00:14:43
![](https://img.aspxhome.com/file/2023/4/104104_0s.png)
javascript中解析四则运算表达式的算法和示例
2024-04-28 09:41:37
![](https://img.aspxhome.com/file/2023/0/132820_0s.png)
python实现跳表SkipList的示例代码
2022-04-05 05:01:53
![](https://img.aspxhome.com/file/2023/3/114783_0s.jpg)
在go文件服务器加入http.StripPrefix的用途介绍
2023-06-26 07:19:07
![](https://img.aspxhome.com/file/2023/1/92031_0s.jpg)
windows10 pycharm下安装pyltp库和加载模型实现语义角色标注的示例代码
2021-11-09 10:58:04
![](https://img.aspxhome.com/file/2023/8/130798_0s.png)
Python中模块pymysql查询结果后如何获取字段列表
2023-07-23 18:52:54
python DataFrame 取差集实例
2021-06-06 01:22:24
Go语言CSP并发模型goroutine及channel底层实现原理
2024-04-28 09:19:10
![](https://img.aspxhome.com/file/2023/5/133995_0s.png)
一文教会你用Python获取网页指定内容
2023-01-01 09:15:05
![](https://img.aspxhome.com/file/2023/4/127774_0s.png)
切换路径在Jupyter里调用本地文件的操作
2022-05-24 15:03:54
![](https://img.aspxhome.com/file/2023/0/66350_0s.jpg)
PyCharm如何导入python项目的方法
2022-10-23 05:50:35
![](https://img.aspxhome.com/file/2023/6/88926_0s.png)
对python中使用requests模块参数编码的不同处理方法
2022-11-02 01:30:29
![](https://img.aspxhome.com/file/2023/8/103688_0s.jpg)
用Python中的字典来处理索引统计的方法
2022-05-28 19:43:45
Python浮点型(float)运算结果不正确的解决方案
2023-10-04 16:57:44
![](https://img.aspxhome.com/file/2023/7/63547_0s.png)