废话少说,直接上代码

function notifyMe(notification_title, body) {
    if (Notification.permission !== "granted")
        Notification.requestPermission();
    else {
        //notification_title,通知标题
        var notification = new Notification(notification_title, {
            //显示通知的图标
            //icon: '',
            //通知的内容
            body: body,
        });

        notification.onclick = function () {
            parent.focus();
            window.focus(); //just in case, older browsers
            this.close();
        };
    }
}

//test
notifyMe("您有新的消息","hello world!")

注意:测试网站必须是https的
开启网站通知,如果开启后收不到通知,再检查下windows系统通知是否允许chrome:
file
file

dropzone 插件只上传一张图片

<div> <div class="col-md-3"> <div class="form-group"> <label>你的头像</label> ...

阅读全文

vue使用v-html渲染的元素绑定事件

//vue html渲染标签,绑定test方法 <div v-html="data" @click="test"></div> //html渲染内容 //<button type="but...

阅读全文

jquery 反转 dom元素

例: <ul> <li>A</li> <li>B</li> <li>C</li> </ul> 需要变成: <ul> <li>C</li>...

阅读全文

欢迎留言