宝哥软件园

Javascript快速实现浏览器系统通知

编辑:宝哥软件园 来源:互联网 时间:2021-09-03

射流研究…实现浏览器的标题闪烁、滚动、声音提示、铬、火狐、Safari等系统通知。

下载

$ npm安装标题-通知-保存-开发$鲍尔安装inotify -保存-开发编译

# 下载依赖工具$ npm安装#压缩iNotify $ NPM buildiniteffect : flash | scroll | favicon var iNotify=new iNotify().init()//推荐下面写法var iNotify=new iNotify({ message : '有消息了。',//标题effect: 'flash ',//flash |滚动闪烁还是滚动openurl:'http://www.bing.com ',//点击弹窗打开连接地址onclick:function(){ //点击弹出的窗之行事件console.log(' - ') },//可选播放声音audio:{ //可以使用数组传多种格式的声音文件file: ['msg.mp4 ',' msg.mp3 ',' msg.wav'] //下面也是可以的哦//file: 'msg.mp4' },//标题闪烁,或者滚动速度interval: 1000,//可选,默认绿底白字的fav icon updatefav icon : {//fav icon字体颜色textColor: '#fff ',//背景颜色,设置背景颜色透明,将值设置为"透明" backgroundColor: '#2F9A00' },//可选铬浏览器通知,默认不填写就是下面的内容notification:{ title: '通知!',//设置标题icon: ' ',//设置图标图标默认为Favicon body: '您来了一条新消息'//设置消息内容}})是权限

判断浏览器弹框通知是否被阻止。

iNotify.isPermission()

声音设置

运动员

播放声音

iNotify.player()自动播放声音

伊诺蒂菲。循环播放()停止播放停止播放声音

伊诺蒂菲。停止播放(setURl)设置播放声音统一资源定位器

iNotify.setURL('msg.mp3')//设置一个iNotify.setURL(['msg.mp3 ',' msg.ogg ',' msg.mp4']) //设置多个标题通知

最新的版本默认不播放标题闪烁动画,初始化之后需要调用设置(真)方法才播放标题动画。

setTitle

设置标题,

iNotify.setTitle(true)//播放动画' iNotify.setTitle('新标题')//闪烁新标题iNotify.setTitle()//清除闪烁显示原来的标题setInterval设置时间间隔

伊诺蒂菲。设置间隔(2000)添加计时器添加计数器

iNotify.addTimer()clearTimer清除计数器

iNotify.clearTimer()favicon通知

setFavicon

设置图标显示数字

伊诺蒂菲。setfavicon(10)清除favicon清除数字显示原来的图标

iNotify.faviconClear()

铬通知

通知

弹出铬通知,不传参数为预设值.

伊诺蒂菲。notify();iNotify.notify({ title: '新通知,body: '打雷啦,下雨啦.openurl:'http://www.bing.com ',onclick : function(){ console。log('-')});其它

iNotify.init().标题;获取标题例子

新iNotify({ effect: 'flash,interval: 500})上面的例子跟下面的是一样的

新iNotify().init({ effect: 'flash,interval : 500 });实例一

函数iconNotify(num){ if(!notify) { var notify=new iNotify().init({ effect: 'flash,interval : 500 });} if(num===0){ notify。favicon clear()。通知。settitle();} else if(num 100){ notify。setfavicon(num)notify。settitle('有新消息!');} else if(num 99){ notify。setfavicon('.)notify.setTitle('有新消息!');}}实例二

var notify=new iNotify().init({ effect: 'flash,interval : 500 });notify.setFavicon('1 ')实例三

var iN=new iNotify().init({ effect: 'flash ',interval: 500,message: '有消息拉!',updateFavicon:{//可选,默认绿底白字textColor: '#fff ',//favicon字体颜色背景色: ' # 2f9a 00 '//背景颜色}}).setFavicon(10);实例四

var iN=new iNotify().init().setFavicon(5);实例五

var iN=new iNotify().init({ effect: 'flash ',interval: 500,message: '有消息拉!',音频: {文件: ' msg。MP4 ' } }).setFavicon(10).player();实例五

Var in=new inotify()。init ({effect:' flash ',interval : 500,message: '有消息!',audio : { file : ' msg . MP4 '//各种格式的声音文件可以使用数组传输},notification : { title : ' notification!',icon: ' ',body: '您有一条新消息' }})。setFavicon(10)。player();//弹出chrome通知,不发送参数为默认值.in . notify();IN.notify({ title: '新通知',body: '雷,雨.'});例6

var in=new inotify({ effect : ' flash ',间隔: 500,消息: '有消息!',audio: {file: ['msg.mp4 ',' msg.mp3 ',' msg.wav']},notification : { title : ' notice!',body: '您有一条新消息' }})iN.setFavicon(10)。player();var n=new inotify()n . init({ effect : ' flash ',interval : 500,message: '有消息!',audio : { file :[' opensub . MP4 ',' opensub.mp3 ',' opensub.wav']},notification : { title : ' notification!',icon: ' ',body: '你有客户' } })n . setfaviicon(10)。player();摘要

以上是边肖介绍的Javascript快速实现浏览器系统的通知,对大家有帮助。如果你有任何问题,请给我留言,边肖会及时回复你。非常感谢您对我们网站的支持!

更多资讯
游戏推荐
更多+