繁体   English   中英

关闭后,保留Chrome扩展程序弹出窗口

[英]Keep a chrome extension popup after close it

我正在开发一个Chrome扩展程序,可以轻松访问一些文档,基本上它是一个弹出式网站。

一切正常,但是当我关闭弹出窗口并再次打开它时,它将重新启动弹出窗口,我想在关闭窗口之前保留用户所在的位置。

有任何想法吗?

------------屏幕截图--------------------

在此处输入图片说明在此处输入图片说明

因此,我想做的是当用户再次打开弹出窗口时,向他显示他正在观看的视图。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM