[英]Keep a chrome extension popup after close it
I'm developing a Chrome extension to have easy access to some documentation, basically it's a website in a popup. 我正在开发一个Chrome扩展程序,可以轻松访问一些文档,基本上它是一个弹出式网站。
It's working OK, but when I close the popup and I open it again, it relaunches the popup and I would like keep where the user was before closing it. 一切正常,但是当我关闭弹出窗口并再次打开它时,它将重新启动弹出窗口,我想在关闭窗口之前保留用户所在的位置。
Any ideas? 有任何想法吗?
------------ screenshots -------------------- ------------屏幕截图--------------------
So.. What I want to do is when the user open again the popup, show him the view he was watching. 因此,我想做的是当用户再次打开弹出窗口时,向他显示他正在观看的视图。
setPopup
is the essential code part you need to recognize. setPopup
是您需要识别的基本代码部分。
if(localStorage.Page && localStorage.Page != document.URL){
//STORE CURRENT PAGE
localStorage.Page = document.URL;
//TRIM STRING
var string = "chrome-extension://"+window.location.host+"/";
String.prototype.ltrim = function() {
return this.replace(string,"");
}
//SETPOPUP OVERWRITES MANIFEST DATA
chrome.browserAction.setPopup({
tabId: null, // Set the new popup for this tab.
popup: localStorage.Page.ltrim() // Open this html file within the popup.
});
}else{
localStorage.Page = document.URL;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.