var options = {
dir: "auto",
body: '老师公开课火热直播中,戳这里进入!免费听 >',
requireInteraction: true,
icon: 'https://img.yutu.cn/yutu/2020/20200421/aaf1ed5391676d9b5cc659d8d8c35076.png'
};
var liveUrl = 'http://www.yutu.cn';
var title = '这里是标题';
if (Notification.permission === 'granted') {
var notification = new Notification(title, options); // 显示通知
notification.onclick = function() {
if ((/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent))) {
location.href = liveUrl;
} else {
window.open(liveUrl);
}
};
notification.onclose = function() {
console.log('点击关闭浏览器提醒');
};
} else if (Notification.permission === 'default') {
// 用户还未选择,可以询问用户是否同意发送通知
Notification.requestPermission(function(permission) {
// 如果用户同意,就可以向他们发送通知
if (permission === 'granted') {
var notification = new Notification(title, options); // 显示通知
notification.onclick = function() {
if ((/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent))) {
location.href = liveUrl;
} else {
window.open(liveUrl);
}
};
notification.onclose = function() {
console.log('点击关闭浏览器提醒');
};
} else if (permission === 'default') {
console.log('用户关闭授权,未刷新页面之前,可以再次请求授权');
} else {
console.log('用户拒绝授权,不能显示通知');
}
});
} else {
console.log('用户曾经拒绝显示通知');
}
注:此方法不支持本地调试,请在http环境下测试var options = { dir: "auto", body: '老师公开课火热直播中,戳这里进入!免费听 >', requireInteraction: true, icon: 'https://img.yutu.cn/yutu/2020/20200421/aaf1ed5391676d9b5cc659d8d8c35076.png' }; var liveUrl =...
//判断非SAFA时用这个
if(!(/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)))
alert("非safari");
//判断是SAFARI时用这个
if((/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.us
--allow-running-insecure-content
默认情况下,https 页面不允许从 http 链接引用 javascript/css/plug-ins。添加这一参数会放行这些内容。
--allow-scri
1. 定义一个派生于WakefulBroadcastReceiver的类
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
private static final String TAG = GcmBroadcastReceiver;
@Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG,
最近一个小伙伴问我,使用Selenium在做自动化测试的时候出现弹窗,但是使用Selenium+Java处理常见的Alert/Confirm弹出框无法找到;于是我就给他介绍了webDriver处理弹窗的所有方法;最后还是不行,于是我就开始怀疑了,决定亲自试一试这到底是个什么妖魔鬼怪。
其中在试的时候我尝试了Selenium切换到所有的Alert,Iframe,window,有点诡异屡试不爽,都找不...
快捷工具先安装1.28版本后用1.31版本替换,以实现视频弹窗和双击关闭标签页功能。
首先下载Chrome扩展快捷工具1.28版的CRX安装包:http://pan.baidu.com/s/1pJ4T4td;
然后拖放到chrome扩展管理页面中安装。
接着,下载打包好的快捷工具1.31版的源码文件:http://pan.baidu.com/s/1mg...
Notification是HTML5新增的API,用于向用户配置和
显示
桌面
通知
。上次在别的网站上看到别人的
通知
弹窗,好奇之余也想知道如何实现的。实际去查一下发现并不复杂,且可以说比较简单,故写篇博客分享给大家,希望能帮你们了解这个API。
npm包:
我还发了一个npm包:notification-Koro1,非常轻量简洁,觉得不错的话,点个Star吧~
chrome下Notification的表...
可以使用Chrome插件的消息传递API来实现Vue网页与
谷歌
插件的交互。具体步骤如下:
1. 在Vue网页中使用chrome.runtime.connect()方法建立与插件的连接。
2. 在插件中使用chrome.runtime.onConnect.addListener()方法监听来自网页的连接请求,并保存连接对象。
3. 在Vue网页中使用chrome.runtime.sendMessage()方法向插件发送消息。
4. 在插件中使用保存的连接对象中的postMessage()方法向网页发送消息。
5. 在插件中使用chrome.browserAction.onClicked.addListener()方法监听插件图标的点击事件,并在回调函数中弹出插件弹窗。
注意事项:
- 插件需要在manifest.json文件中声明"background"权限才能使用chrome.runtime.onConnect.addListener()方法监听连接请求。
- 插件需要在manifest.json文件中声明"browser_action"权限才能使用chrome.browserAction.onClicked.addListener()方法监听图标点击事件。
- 网页和插件之间的消息传递需要使用相同的消息格式,建议使用JSON格式。
- 在弹出插件弹窗时,需要在插件的manifest.json文件中声明弹窗的HTML文件路径。