如何以编程方式打开Chrome扩展程序popup.html [英] How to programmatically open chrome extension popup.html

查看:758
本文介绍了如何以编程方式打开Chrome扩展程序popup.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用google扩展程序创建了一个桌面通知,它很好用:

  icon =''; 
var popup = window.webkitNotifications.createNotification(my notification');
图标,'真棒标题','点击此处查看更多。 );
popup.show();

有没有办法启动实际的google扩展程序popup.html(如下图所示) ,当用户点击桌面通知时?


< img src =https://i.stack.imgur.com/MwIc6.pngalt =桌面通知>



谢谢。

解决方案

简短的回答是你不能,但是如果你想在新标签中打开弹出窗口,你会怎么做:



在你打电话给 show


$ b之前$ b

  popup.onclick = function(){
chrome.tabs.create({url:popup.html});
popup.cancel();
}


I have a created a desktop notification using google extension which works great:

icon = '';
    var popup = window.webkitNotifications.createNotification(my notification');
            icon, 'Awesome title', 'Click here to view more. ');
    popup.show();

Is there a way to launch the actual google extension popup.html (as shown on the image below), when the user click on the the desktop notification?

Thanks.

解决方案

Short answer is that you can't, but if you want to open the popup in a new tab instead, this is how you would do it:

Put this before you call show

popup.onclick = function() { 
    chrome.tabs.create({url : "popup.html"}); 
    popup.cancel();
}

这篇关于如何以编程方式打开Chrome扩展程序popup.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆